Assignment:
Below is a code file that works accept when a correct dollar amount an location number is entered, the result flashes on the screen and disappears. How do I get the output results to stay on the screen?
#include
/*Using define macros for assigning tax to different stores */
#define DelMar 7.25
#define Encinitas 7.5
#define LaJolla 7.75
/*
Input:
? Del Mar - 7.25%
? Encinitas - 7.5%
? La Jolla - 7.75%
Output:
The sales tax amount for each store of the $ Purchase amount for each.
*/
float user_input(){
float amount;
printf("Please Enter the sales amount\n");
scanf("%f", &amount);
fflush(stdin);
return amount;
}
int displayMenu(){
int choice;
printf("1. Del Mar - (7.25%%)\n");
printf("2. Encinitas - (7.5%%)\n");
printf("3. La Jolla - (7.75%%)\n");
printf("\n\nSelect a store for tax calculation [1-3]:");
scanf("%d",&choice);
return choice;
}
int main(){
// The total sales for each store is
float sales = 0.00;
int storenum;
sales = user_input();
if (sales <= 0.0) {
printf(" \n");
printf("ERROR! Sales must be greater than 0.00");
}
storenum = displayMenu();
//Display Program Header
printf(" \n");
printf(" Tax Calculator for Kudler Fine Foods\n\n\n");
printf("STORE LOCATION\tSALES AMOUNT\tTAX RATE\tTAX AMOUNT\n");
printf("==============\t============\t========\t==========\n");
printf("==============\t============\t========\t==========\n");
switch (storenum){
case 1:
//Calculate and print the store location, Sales, Tax rate, and Tax amnt for Del Mar
printf("Del Mar \t$%.2f\t\t%.2f%%\t\t%.2f%\t\n",sales, DelMar, sales*DelMar/100);
break;
case 2:
//Calculate and print the store location, Sales, Tax rate, and Tax amnt for Encinitas
printf("Encinitas\t$%.2f\t\t%.2f%%\t\t%.2f%\t\n",sales, Encinitas, sales*Encinitas/100);
break;
case 3:
//Calculate and print the store location, Sales, Tax rate, and Tax amnt for La Jolla
printf("La Jolla \t$%.2f\t\t%.2f%%\t\t%.2f%\t\n",sales, LaJolla, sales*LaJolla/100);
break;
} //Switch ends
printf("================================================================\n");
printf(" +++++++++++++++++++++++++++\n");
printf(" ### Press ENTER to Exit Program ###\n");
printf(" +++++++++++++++++++++++++++\n");
getchar();
return 0;
}