I gave up on having the program restart from within for now. I will
try that later. I think I tried to many things at once. I now cannot
get the program to compile. I added an if statement with two
conditions. Isn't that possible? I don't know why I try these things
when they are not required. It's addicting. Any advice will be
appreciated.
Here is the error code:
"C:\Program Files\Miracle C\examples\merle.c: line 48: unrecognised
types in comparison
'if (iResponse < 1.0 || iResponse > 3.0) printf ("\n Please enter a
response of 1, 2 or 3.")'
aborting compile"
Here is the program code:
/*original version Merle Hall CSS561 week 5 individual assignment*/
/*Change request for tax calculation program at Kudler Stores*/
/*June 7, 2008*/
/* ver 2 removed extra semi-colons*/
/* ver 3 added braces in function */
/* ver 4 added conversion specifier*/
/* ver 5 reworked formula for total*/
/* ver 6 added input statement for amount*/
/* ver 7 added if then for verificaton of amount*/
/* ver 7.5 resolve typo issue on printf*/
/* ver 8 resoved issue with if statement changed to while loop*/
#include <stdio.h>
#include <math.h>
int main()
{
/*setting variables for store choice*/
int iQuit;
int iResponse;
float fSales;
float fTax1;
float fTax2;
float fTax3;
float fTotal1;
float fTotal2;
float fTotal3;
/*initializing variables*/
iQuit = 0;
iResponse = 0;
fSales = 0;
fTax1 = .0725;
fTax2 = .075;
fTax3 = .0775;
fTotal1 = 0;
fTotal2 = 0;
fTotal3 = 0;
/*switch for selecting store location*/
{
printf ("\n\tStore Location");
printf ("\n1\t Del Mar\n");
printf ("\n2\t Encinitas\n");
printf ("\n3\t La Jolla\n");
printf ("\n Enter the number of your store location: ");
scanf ("%d", &iResponse );
}
if (iResponse < 1.0 || iResponse > 3.0)
printf ("\n Please enter a response of 1, 2 or 3.");
else
/*function for inputing sales*/
printf ("\nEnter amount of purchase:\n");
scanf ("%f", &fSales);
/*formulas for figuring totals*/
fTotal1 = (fTax1 * fSales) + fSales;
fTotal2 = (fTax2 * fSales) + fSales;
fTotal3 = (fTax3 * fSales) + fSales;
/*while loop for input*/
while (fSales <= 0.00)
{
printf ("\n Please enter a valid amount");
scanf ("%f", &fSales);
}
/* functions for printing output*/
{
printf ("\nThe amount you entered was: %.2f\n", fSales);
}
if (iResponse ==1){
printf ("\nYour tax rate at the Del Mar store is %.4f", fTax1);
printf ("\nYour tax on your purchase amount at the Del Mar store
is %.2f", fTax1 * fSales);
printf ("\nYour total at the Del Mar store is %.2f\n", fTotal1);
}
if (iResponse ==2){
printf ("\nYour tax rate at the Encinitas store is %.4f", fTax2);
printf ("\nYour tax on your purchase amount at the Encinitas store
is %.2f", fTax2 * fSales);
printf ("\nYour total at the Encinitas store is: %.2f\n", fTotal2);
}
if (iResponse ==3){
printf ("\nYour tax rate at the La Jolla store is %.4f", fTax3);
printf ("\nYour tax on your purchase amount at the La Jolla store
is %.2f", fTax3 * fSales);
printf ("\nYour total at the La Jolla store is %.2f", fTotal3);
}
printf ("\n Enter 4 to quit");
scanf ("%d", &iQuit);
if (iQuit == 4)
return 0;
}