Purchase Solution

How do I get the output results to stay on the screen?

Not what you're looking for?

Ask Custom Question

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 <stdio.h>

/*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;
}

Purchase this Solution

Solution Summary

This solution discusses how to get output results to stay on the screen.

Solution Preview

Hi
Please use getch() instead of getchar()

this function will pause the screen until you input something form the
keyboard .
You can use it at any location where u want to pause the screen.

Thanks
102833

#include <stdio.h>

/*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 ...

Purchase this Solution


Free BrainMass Quizzes
Word 2010: Tables

Have you never worked with Tables in Word 2010? Maybe it has been a while since you have used a Table in Word and you need to brush up on your skills. Several keywords and popular options are discussed as you go through this quiz.

Word 2010: Table of Contents

Ever wondered where a Table of Contents in a Word document comes from? Maybe you need a refresher on the topic? This quiz will remind you of the keywords and options used when working with a T.O.C. in Word 2010.

Excel Introductory Quiz

This quiz tests your knowledge of basics of MS-Excel.

Inserting and deleting in a linked list

This quiz tests your understanding of how to insert and delete elements in a linked list. Understanding of the use of linked lists, and the related performance aspects, is an important fundamental skill of computer science data structures.

Basic Computer Terms

We use many basic terms like bit, pixel in our usual conversations about computers. Are we aware of what these mean? This little quiz is an attempt towards discovering that.