Solved

menu for tax calculator

Posted on 2006-06-17
16
2,040 Views
Last Modified: 2009-07-07
i work for the hole tax consulting corp i had created this program below changed variables to not show the company materials.   i have to modify the C program so that the user inputs the purchase amount. Check the user’s input for validity. Have the user select from a menu which store to use for the tax calculation. Calculate and display the tax amount for the store selected and the total sale amount for that store.  can you please help me.




 # include <stdio.h>
void main(void)
{
//entering the variables in float
  float cost = 0.0;
  float delmar = .0725;
  float encinitas = .075;
  float lajolla = .0775;
//entering
  printf ("enter sales price please\n");
  scanf ("%f",& cost);
  printf ("the delmar sales tax is %.2f\n", delmar * cost);
  printf ("the encinitas sales tax is %.2f\n", encinitas * cost);
  printf ("the lajolla sales tax is %.2f\n", lajolla * cost);
  printf ("\n");
  printf ("the total for delmar is %.2f\n", delmar * cost + cost);
  printf ("the total for encinitas is %.2f\n", encinitas * cost +
  cost);
  printf ("the total for lajolla is %.2f\n", lajolla * cost + cost);
  getchar();
}


0
Comment
Question by:mannyfresco
  • 4
  • 4
  • 3
  • +1
16 Comments
 
LVL 16

Accepted Solution

by:
PaulCaswell earned 125 total points
ID: 16927374
Hi mannyfresco,

There's a special page for 'C' questions. Would you like me to move this question there?

Paul <C Page Editor>
0
 
LVL 20

Expert Comment

by:alainbryden
ID: 16927737
If by create a menu you mean have some sort of graphical user interface for entering prices and purchases, you are way on the wrong track using C99
0
 
LVL 4

Expert Comment

by:programmer1024
ID: 16928036
#include <iostream>
using namespace std;
//Code written by Programmer1024, (c) 2006 Programmer1024
int Menu();

void main() {

float cost = 0.0;
float delmar = 0.0725;
float encinitas = 0.075;
float lajolla = 0.0775;
int choice;

cout << "Enter the sales price: \n";
cin >> cost;

choice = Menu();

switch(choice){

case 1:
cout << "\nThe total for delmar is $" << delmar * cost + cost << "\n";
break;

case 2:
cout << "\nThe total for encinitas is $" << encinitas * cost + cost << "\n";
break;

case 3:
cout << "\nThe total for lajolla is $" << lajolla * cost + cost << "\n";
break;

}
}

int Menu() {
int ch;

cout << "Please select a menu choice:\n";
cout << "------------------------------\n";

cout << "1. Delmar sales tax rate.\n";
cout << "2. Encinitas sales tax rate.\n";
cout << "3. Lajolla sales tax rate.\n";

cin >> ch;

return ch;

}
0
 
LVL 20

Expert Comment

by:alainbryden
ID: 16928044
He is using C99, not C++, your code does not apply programmer1024
0
 
LVL 4

Expert Comment

by:programmer1024
ID: 16928100
Sorry Paul. If you want to remove my post until you can confirm the question's authenticity, please feel free.
0
 
LVL 4

Expert Comment

by:programmer1024
ID: 16928102
Oops, you're right 'bryden.
0
 
LVL 16

Expert Comment

by:PaulCaswell
ID: 16929085
No probs programmer1024. I think asker wants C and your C++ demonstrates how to do it but not what to do, which is ideal I think.

Paul
0
What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

 

Author Comment

by:mannyfresco
ID: 16934993
this is not homework
0
 

Author Comment

by:mannyfresco
ID: 16939450
i dont want an answer i just want to know how to create a menu what is the command that is all.  i know how to printf and loop
0
 

Author Comment

by:mannyfresco
ID: 16941734
# include <stdio.h>
void main(void)
{

int iResponse = 0;
//entering the variables in float
  float cost = 0.0;
  float delmar = .0725;
  float encinitas = .075;
  float lajolla = .0775;
//entering
  printf("\n1\tlajolla\n");
printf("2\tdelmar\n");
printf("3\tencinitas\n");
printf("\nPlease select a category (1—3): ");
scanf("%d", &iResponse);
switch (iResponse) {
case 1:
printf("\nYou selected la jolla\n");
case 2:
printf("You selected delmar\n");
case 3:
printf("You selected encinitas\n");
  printf ("enter sales price please\n");
  scanf ("%f",& cost);
  printf ("the delmar sales tax is %.2f\n", delmar * cost);
  printf ("the encinitas sales tax is %.2f\n", encinitas * cost);
  printf ("the lajolla sales tax is %.2f\n", lajolla * cost);
  printf ("\n");
  printf ("the total for delmar is %.2f\n", delmar * cost + cost);
  printf ("the total for encinitas is %.2f\n", encinitas * cost +
  cost);
  printf ("the total for lajolla is %.2f\n", lajolla * cost + cost);
  getchar();
}

got it a little better still doesnt compile help thanks.
0
 
LVL 16

Expert Comment

by:PaulCaswell
ID: 16946070
This should get you going:

Change:

printf("You selected encinitas\n");
  printf ("enter sales price please\n");

to

printf("You selected encinitas\n");
}
  printf ("enter sales price please\n");

Track each error from its line number. You WILL get them all in the end. This self-discipline is one of the most difficult to learn in programming. There is no point trying to avoid it. Your program wont run until it compiles.

Paul
0
 

Author Comment

by:mannyfresco
ID: 16948107
thanks for your advice all that happened was that i used microsoft word to create the program then i copied and pasted into the c compiler.  i got the answer done.
0
 
LVL 4

Expert Comment

by:programmer1024
ID: 16948286
Soo...points???
0
 
LVL 20

Expert Comment

by:alainbryden
ID: 16951674
I think he's handing out about as many points as he's getting for doing this assignment :P
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Reading variable length EBCDIC in SAS 9 76
commonTwo  challenge 63 99
creating threads in delphi 1 54
Currency Conversion? 1 37
Entering a date in Microsoft Access can be tricky. A typo can cause month and day to be shuffled, entering the day only causes an error, as does entering, say, day 31 in June. This article shows how an inputmask supported by code can help the user a…
Whether you’re a college noob or a soon-to-be pro, these tips are sure to help you in your journey to becoming a programming ninja and stand out from the crowd.
In this fifth video of the Xpdf series, we discuss and demonstrate the PDFdetach utility, which is able to list and, more importantly, extract attachments that are embedded in PDF files. It does this via a command line interface, making it suitable …
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…

757 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

17 Experts available now in Live!

Get 1:1 Help Now