Attached 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 amountn");
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("nnSelect 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 Foodsnnn");
printf("STORE LOCATIONtSALES AMOUNTtTAX RATEtTAX AMOUNTn");
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$%.2ftt%.2f%%tt%.2f%tn",sales, DelMar, sales*DelMar/100);
break;
case 2:
//Calculate and print the store location, Sales, Tax rate, and Tax amnt for Encinitas
printf("Encinitast$%.2ftt%.2f%%tt%.2f%tn",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$%.2ftt%.2f%%tt%.2f%tn",sales, LaJolla, sales*LaJolla/100);
break;
} //Switch ends
printf("================================================================n");
printf(" +++++++++++++++++++++++++++n");
printf(" ### Press ENTER to Exit Program ###n");
printf(" +++++++++++++++++++++++++++n");
getchar();
return 0;
}
Attachment:- 119930-StoreTax-2.zip