Shadow-Ninja
asked on
Modify the calculator.
Hello all. I bet you are tired of this calculator. Anyway, to my question. This part is part 1 of three. This week I have to modify the calculator to get the user to input purchase amount, then check the validity, calculate and display the total sale amount for each location. Please do not think I am after the quick answer here. I respect everyone in here for there time and knowledge. My problems are many but any guidance to help me in the right direction would be appreciated. I have asked a few classmates and my instructor for guidance but have not recieved any word from them. I kind of feel like the class pest.
Here are my questions:
Do I need to rewrite the program in a different way to get these modifications?
Do I need to use a loop function or array's or is it just preference?
I do not want to ask anymore, I think I am asking to much already. Thank you for any possible help.
#include <stdio.h>
float calculateTax(float SalesPrice, float tax);
main()
{
int iResponse = 0;
printf("\n1\tDel Mar = .0725\n");
printf("2\tEncinitas = .075\n");
printf("3\tLa Jolla = .0775\n");
printf("\nPlease select your proper tax (1-3): ");
scanf("%d", &iResponse);
switch (iResponse) {
case 1:
printf("\nYour total is %.2f\n",calculateTax(125.0 0,.0725)+1 25.00);
break;
case 2:
printf("Your total is %.2f\n",calculateTax(125.0 0,.075)+12 5.00);
break;
case 3:
printf("Your total is %.2f\n",calculateTax(125.0 0,.0775)+1 25.00);
break;
}
getch();
} // end switch
float calculateTax(float SPrice, float tax) {
return(SPrice * tax);
}
Here are my questions:
Do I need to rewrite the program in a different way to get these modifications?
Do I need to use a loop function or array's or is it just preference?
I do not want to ask anymore, I think I am asking to much already. Thank you for any possible help.
#include <stdio.h>
float calculateTax(float SalesPrice, float tax);
main()
{
int iResponse = 0;
printf("\n1\tDel Mar = .0725\n");
printf("2\tEncinitas = .075\n");
printf("3\tLa Jolla = .0775\n");
printf("\nPlease select your proper tax (1-3): ");
scanf("%d", &iResponse);
switch (iResponse) {
case 1:
printf("\nYour total is %.2f\n",calculateTax(125.0
break;
case 2:
printf("Your total is %.2f\n",calculateTax(125.0
break;
case 3:
printf("Your total is %.2f\n",calculateTax(125.0
break;
}
getch();
} // end switch
float calculateTax(float SPrice, float tax) {
return(SPrice * tax);
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
The for loop function, sorry...
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
I think I have the location part taken care of. When you select your choice it outputs your slection with total. I just need to know if I am close or do I need glasses. The user input is seeming more tricky to me than I for saw. Is it possible to elaborate on this further without compromising any of your ethics in academic honesty. If you can go no further I understand. I do not want to act dishonest in turning my project in. I would rather get an incomplete than to cheat. I will check back later to see. Thank you to all who have helped. If no more answers are available due to academic honesty and rstrictions I will award them in them morning. Again, thanks for all of the advice, You Guys "ROCK"
#include <stdio.h>
float calculateTax(float SalesPrice, float tax);
main()
{
int iResponse = 0;
printf("\nPlease Purchase Amount: 125.00\n");
printf("\n**************** ********** ********** ****\n");
printf("\n1\tDel Mar = .0725\n");
printf("2\tEncinitas = .075\n");
printf("3\tLa Jolla = .0775\n");
printf("\n**************** ********** ********** ****\n");
printf("\nPlease select your proper tax (1-3): ");
scanf("%d", &iResponse);
printf("\nThank You\n");
if (iResponse == 1)
printf("\nYou have chosen Del Mar tax\n");
if (iResponse == 2)
printf("\nYou have chosen Encinitas tax\n");
if (iResponse == 3)
printf("\nYou have chosen La Jolla tax\n");
switch (iResponse) {
case 1:
printf("\nYour total is %.2f\n", calculateTax(125.00, .0725)+125.00);
break;
case 2:
printf("Your total is %.2f\n", calculateTax(125.00, .075)+125.00);
break;
case 3:
printf("Your total is %.2f\n", calculateTax(125.00, .0775)+125);
break;
}
getch();
} // end switch
float calculateTax(float SPrice, float tax) {
return(SPrice * tax);
}
#include <stdio.h>
float calculateTax(float SalesPrice, float tax);
main()
{
int iResponse = 0;
printf("\nPlease Purchase Amount: 125.00\n");
printf("\n****************
printf("\n1\tDel Mar = .0725\n");
printf("2\tEncinitas = .075\n");
printf("3\tLa Jolla = .0775\n");
printf("\n****************
printf("\nPlease select your proper tax (1-3): ");
scanf("%d", &iResponse);
printf("\nThank You\n");
if (iResponse == 1)
printf("\nYou have chosen Del Mar tax\n");
if (iResponse == 2)
printf("\nYou have chosen Encinitas tax\n");
if (iResponse == 3)
printf("\nYou have chosen La Jolla tax\n");
switch (iResponse) {
case 1:
printf("\nYour total is %.2f\n", calculateTax(125.00, .0725)+125.00);
break;
case 2:
printf("Your total is %.2f\n", calculateTax(125.00, .075)+125.00);
break;
case 3:
printf("Your total is %.2f\n", calculateTax(125.00, .0775)+125);
break;
}
getch();
} // end switch
float calculateTax(float SPrice, float tax) {
return(SPrice * tax);
}
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
This is what I have now. It compiles but I still think there is one thingmissing and I also think I wrote more code than neccessary to achieve this goal, which I do not mind. I learned and that is the most important thing.
#include <stdio.h>
float calculateTax(float SalesPrice, float tax);
main()
{
int iResponse = 0; //Gives value to my integer
float fPurchase = 125.00;//The amount of the purchase being made
float fDelMar = .0725;//This locations tax
float fEncinitas = .075;//This locations tax
float fLaJolla = .0775;//This locations tax
printf("\nWelcome to Kudler Fine Foods\n"); //Greeting
printf("\nPlease select your Local Tax\n"); //Prompts for user input
printf("\n**************** ********** ********** ****\n"); //Outlines my menu
printf("\n1\tDel Mar = .0725\n");/////
printf("2\tEncinitas = .075\n");//////////// These are tax percentages for each location
printf("3\tLa Jolla = .0775\n");////
printf("\n**************** ********** ********** ****\n");
printf("\nPlease select your proper tax (1-3): "); //Ask for input
scanf("%d", &iResponse);
printf("\nThank You\n"); //Manners,LOL
if (iResponse == 1) {
printf("\nEnter Amount Purchased: ");
scanf("%f", &fPurchase); //Gives tax,purchase amount,and totalfor the this Response
printf("\nYour Total: $%.2f\n" fDelMar, fPurchase);//Multiplies my purchase with the correct tax for this location
}//end if
if (iResponse == 2) {
printf("\nEnter Amount Purchased: ");
scanf("%f", &fPurchase); //Gives tax,purchase amount, and total for this response
printf("\nYour Total: $%.2f\n", fEncinitas, fPurchase); //Multiplies my purchase with the correct tax for this location
}//end if
if (iResponse == 3) {
printf("\nEnter Amount Purchased: ");
scanf("%f", &fPurchase); //Gives tax, purchase amount, and total for this response
printf("\nYour Total: $%.2f\n", fLaJolla, fPurchase); //multiplies my purchase with the correct tax for this location
}//end if //ends the if structures
switch (iResponse){ // Begins my switch
case 1:
printf("\nYour total is %.2f\n", calculateTax(125.00, .0725)+125.00);
break;
case 2:
printf("Your total is %.2f\n", calculateTax(125.00, .075)+125.00);
break;
case 3:
printf("Your total is %.2f\n", calculateTax(125.00, .0775)+125);
break;
}
getch();
} // end switch
float calculateTax(float SPrice, float tax) {
return(SPrice * tax);
}
#include <stdio.h>
float calculateTax(float SalesPrice, float tax);
main()
{
int iResponse = 0; //Gives value to my integer
float fPurchase = 125.00;//The amount of the purchase being made
float fDelMar = .0725;//This locations tax
float fEncinitas = .075;//This locations tax
float fLaJolla = .0775;//This locations tax
printf("\nWelcome to Kudler Fine Foods\n"); //Greeting
printf("\nPlease select your Local Tax\n"); //Prompts for user input
printf("\n****************
printf("\n1\tDel Mar = .0725\n");/////
printf("2\tEncinitas = .075\n");//////////// These are tax percentages for each location
printf("3\tLa Jolla = .0775\n");////
printf("\n****************
printf("\nPlease select your proper tax (1-3): "); //Ask for input
scanf("%d", &iResponse);
printf("\nThank You\n"); //Manners,LOL
if (iResponse == 1) {
printf("\nEnter Amount Purchased: ");
scanf("%f", &fPurchase); //Gives tax,purchase amount,and totalfor the this Response
printf("\nYour Total: $%.2f\n" fDelMar, fPurchase);//Multiplies my purchase with the correct tax for this location
}//end if
if (iResponse == 2) {
printf("\nEnter Amount Purchased: ");
scanf("%f", &fPurchase); //Gives tax,purchase amount, and total for this response
printf("\nYour Total: $%.2f\n", fEncinitas, fPurchase); //Multiplies my purchase with the correct tax for this location
}//end if
if (iResponse == 3) {
printf("\nEnter Amount Purchased: ");
scanf("%f", &fPurchase); //Gives tax, purchase amount, and total for this response
printf("\nYour Total: $%.2f\n", fLaJolla, fPurchase); //multiplies my purchase with the correct tax for this location
}//end if //ends the if structures
switch (iResponse){ // Begins my switch
case 1:
printf("\nYour total is %.2f\n", calculateTax(125.00, .0725)+125.00);
break;
case 2:
printf("Your total is %.2f\n", calculateTax(125.00, .075)+125.00);
break;
case 3:
printf("Your total is %.2f\n", calculateTax(125.00, .0775)+125);
break;
}
getch();
} // end switch
float calculateTax(float SPrice, float tax) {
return(SPrice * tax);
}
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Thanks, I appreciate everyone who helped me and also by helping it be honest. I liked that you helped me but kept it to where I was able to learn it mostly by my deducing the problem. I was going to terminate my membership but since I was treated with respect and was not given the answer I am going to stay. Thank you, and have a great day. I have spread the points out appropiatly....
ASKER