Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

void welcome ( ) - This function prints a welcome message to the user. void displayMenu ( ) - This function prints the menu to

void welcome()- This function prints a welcome message to the user.
void displayMenu()- This function prints the menu to the user. Your menu must have 2 items - Place an order and quit. Here is an example:
Place an order
Quit
void readOption(int &option).
This function will read an option and return to the called function through the reference parameter.
Call the readInt function to do this. You must catch all invalid data such as characters, negative numbers etc.
You must also do validation to make sure that the number is 1 or 2 and nothing other than that. Use a while loop to do this.
void readInt(string prompt, int &num)
This function should be used any time you read any integers from the user. Use this function to read the menu option from the user.
It takes a string prompt, outputs it, reads a number from the user, validates and returns the num by reference.
See Samplea01.cpp for the function. You may use the function in the sample.
You must catch all invalid data such as characters, negative numbers etc.
void readDouble(string prompt, double &num)
This function should be used any time you read any floats or doubles from the user. Use this function to read the cost of the item, tip, etc from the user.
It takes a string prompt, outputs it, reads a number from the user, validates and returns the num by reference.
Write it exactly like the readInt but declare a double or float instead of an int.
You must catch all invalid data such as characters, negative numbers etc.
void placeOrder(double &cost)
Call this function if the user selects 1 from the menu.
This function will go through a loop and ask the user to enter item names and their cost until the user answers n to the question - Do you want another item? (y/n): You must validate to make sure the user enters y/n for this question (it should not be case sensitive - must accept both uppercase and lowercase). Use a while loop to do this.
The total cost must be returned through the reference parameter and be printed in main().
Call the readDouble function to do this. You must catch all invalid data such as characters, negative numbers etc.
Do not print anything in this function. The tip, discount, and final total must be printed in main().
double tipDiscount(double &tip, double &discount, double cost).
This function takes the cost by value, and the tip and discount by reference.
The function prompts the user to enter a tip amount, and reads into the tip parameter. This will be used to calculate the total, and it will also go back to main() so it can be printed in main().
Call the readDouble function to do this. You must catch all invalid data such as characters, negative numbers etc.
It then calculates the discount based on the total (including the tip), and returns the final total to main(). The discount amount goes back by reference to be printed in main(). See sample run.
Do not print anything inside the function.
int main()
Declare all variables needed.
Call the displayMenu function.
Call the readOption function.
There must be a do-while loop in main that will keep repeating the menu until the user enters 2.
When the user enters 1, call the placeOrder function.
Then call the tipDiscount function that will calculate the final total and return the value. It will also receive the tip and discount amount by reference.
Print the tip, discount and final total when it comes back. Repeat the menu and continue until the user enters option 2.
Print dollar amounts with a $ sign and output to 2 decimal places.
When the user enters 2, quit the program after printing a thank you message.
Open the Algorithmic Design Document, make a copy, and follow the steps to create your algorithm.
You must express your algorithm as pseudocode.
Check out all the coding constructs under Criteria for Success.
Welcome to my Food Cart Program!
What would you like to do today?
Pick an option from below:
Place an order
Quit
>>9
Invalid Option! Please choose 1-2!
>1
Enter the name of your item: Pasta
Enter the cost of your item $15.75
Do you want another item? (yn):y
Enter the name of your item: Bowl
Enter the cost of your item $12.75
Do you want another item? (yn):y
Enter the name of your item: Soda
Enter the cost of your item $: 3.50
Do you want another item? (yn):x
Invalid Option! Please choose yn!
>n
Your total is: $32.00
Enter the amount of tip you want to add $: 3.50
Your total is: $35.50
You get a 5% discount!
Your discount is $1.78
Your final total is: $33.73
What would you like to do today?
Pick an option
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Filing And Computer Database Projects

Authors: Jeffrey Stewart

2nd Edition

007822781X, 9780078227813

More Books

Students also viewed these Databases questions

Question

fscanf retums a special value EOF that stands for...

Answered: 1 week ago

Question

5. To determine the financial benefits and costs of the program.

Answered: 1 week ago