Thanks Yellow Snow, I am going to give that a try.
Can you help me on something stupid real quick? I have two copies of my code saved, one works and one does not (as you pointed out). For the life of me I cannot see the difference.
Can you look as this working version and tell me what is different?
I have gone through line by line and both versions look identical to me.
#include <stdio.h> // standard input output library
//defines tax value for calculations
#define DelMar 7.25
#define Encinitas 7.5
#define LaJolla 7.75
char cAgain; //variable for Y/N questions
float user_input() // week 4 addition for sales amount
{ //prompt, collect, and store sale amount
float fAmount; //defines amount type as float
printf("Enter Amount of Sale $ ");
scanf ("%f", &fAmount);
return fAmount;
}
int iMenu() //defines menu variable
{ // menu which prompts, collects, and stores store number
int iSelection; //defines selection type as integer
printf("Tax Calculation for Purchase\n\n"); //changed to reflect week 4 updates
printf("1. Del Mar \n2. Encinitas \n3. La Jolla\n");
printf("\n\nPlease Select Number of Store for Which to Calculate: ");
scanf("%d",&iSelection);
return iSelection;
}
int main() //main loop
{
STARTOVER://start again point
{
float fSales = 0.00; // Sales value for calculations
int iStorenum; //defines store for main loop, menu will not work without
fSales = user_input(); //new week 4 loop for sales total
while (fSales <0.0) //new week 4 loop to validate sales amount
{
printf("SALE AMOUNT CANNOT BE LESS THAN $0.00. Re-Enter: $ ");
{
scanf ("%f",&fSales); // scans new input for validity
}
} // ends while loop
iStorenum = iMenu(); //displays menu created above
while (iStorenum <1 || iStorenum >3) //if store number is not 1, 2 or 3
{
printf("INVALID NUMBER ENTERED! Please enter 1,2 or 3: ");
{
scanf("%d", &iStorenum); //scans input at INVALID prompt
}
} // end while loop
if (iStorenum == 1)
//Calculates and Displays Del Mar Store, Sales, Tax rate, and Tax
printf("\nDel Mar \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, DelMar, fSales*DelMar/100, DelMar*fSales/100+fSales);
if (iStorenum == 2)
//Calculates and Displays Encinitas Store, Sales, Tax rate, and Tax
printf("\nEncinitas \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, Encinitas, fSales*Encinitas/100, Encinitas*fSales/100+fSales);
if (iStorenum == 3)
//Calculates and Displays La Jolla Store, Sales, Tax rate, and Tax
printf("\nLa Jolla \tSale $%.2f\tRate %.2f%%\tTax $%.2f%\tTotal= \t$%.2f\t\n\n",fSales, LaJolla, fSales*LaJolla/100, LaJolla*fSales/100+fSales);
printf("\n\tRun Calculator Again? (y/n) ");//prompts for repeat
scanf("%c", &cAgain);//scans input at store number prompt
if (cAgain == 'y'|| cAgain == 'Y')//repeats calculator
{
goto STARTOVER; //back to top
}
else if (cAgain == 'n' || cAgain == 'N')//end
return 0; // successful loop end
}
}