I am still reading up on switches. However your help was greatly
appreciated. I went back and looked at my semicolons and brace
placement. Now my program will run but it doesn't do the math. My
output is
"Your tax is"
"Your total is"
Did I do something wrong with my printf statements? or should I have
used a constant instead of a float?
here is the revised code:
/*original version*/
#include <stdio.h>
#include <math.h>
main()
{
/*setting variables for store choice*/
int iResponse;
float fSales;
float fTax1;
float fTax2;
float fTax3;
float fTotal1;
float fTotal2;
float fTotal3;
/*initializing variables*/
iResponse = 0;
fSales = 0;
fTax1 = .0725;
fTax2 = .075;
fTax3 = .0775;
fTotal1 = fTax1 * fSales;
fTotal2 = fTax2 * fSales;
fTotal3 = fTax3 * fSales;
/*function for selecting store location*/
printf ("\n\tStore location");
printf ("\n1\t Del Mar\n");
printf ("\n2\t Encinitas\n");
printf ("3\t La Jolla\n");
printf ("\nEnter the number of your store location: ");
scanf ("%d", &iResponse);
/*function for inputing sales*/
printf ("\nEnter amount of purchase:");
scanf ("%f", &fSales);
/*function for conditions*/
if (iResponse ==1){
printf ("\nYour tax is", "fTax1 * fSales");
printf ("\nYour total is", "fTotal1");
}
if (iResponse ==2){
printf ("\nYour tax is", fTax2 * fSales);
printf ("\nYour total is", fTotal2);
}
if (iResponse ==3){
printf ("\nYour tax is", fTax3 * fSales);
printf ("\nYour total is", fTotal3);
}
if (iResponse > 3)
printf ("\nYour choice has to be 1,2 or 3\n");
}