Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

For this program, you will need to write 4 functions, as follows: calculateBill Takes in a double reference parameter for the price of the food.

For this program, you will need to write 4 functions, as follows:

calculateBill

Takes in a double reference parameter for the price of the food.

Takes in a double value parameter for the chosen tip percent

calls the addTax function to add taxes to the price.

calls the calculateTip function to add the tip to the price.

calls the formatPrice function to print out the price

returns nothing

addTax

Takes in a double reference parameter for the price of the food.

Updates the price by adding on the tax, assuming the tax rate is 9.25% in Santa Clara County

returns nothing

calculateTip

Takes in a double reference parameter for the current bill (price + tax).

Takes in a second double - this time a value parameter - for the percent tip.

Calculates the amount of the tip and updates the current price by adding on the tip amount

returns nothing

formatPrice

Takes in a double value parameter for the price.

prints the price in the form $X.XX

(Hint: How do you get the price to have only 2 decimal values?)

Also prints a message about the final price: "With tax and tip, your total comes to... $"

returns nothing

Additional Specifications

You must include function prototypes at the top of your program.

Each prototype must also have a comment in the style describe.

You should write the full function definitions below main.

Important: You should call the calculateBill function inside of main, not the other three functions.

The other 3 functions should be called inside of the calculateBill function.

The code is below:

void calculateBill(double& price, double percent); //calls addTax, calculateTip and displayPrice //to calculate and display the final price

void addTax(double& price); //calculates the tax at 9.25% and adds it to the price of the meal

...... int main() { cout << "Welcome to the Restaurant Calculator "; cout << " Enter the price of your meal: "; double price; cin >> price; double percent; cout << "Enter the percent tip (10-25): "; cin >> percent; calculateBill(price, percent); cout << "Goodbye!"; } void addTax(double& price) { price *= 1.0925; } void calculateBill(double& price, double percent) { addTax(price); //add two additional function calls here }

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

MySQL Crash Course A Hands On Introduction To Database Development

Authors: Rick Silva

1st Edition

1718503008, 978-1718503007

More Books

Students also viewed these Databases questions