Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Part 1: Pizza Price Calculator Size S (10) M(13) L(16) Base Price $6.99 $9.99 $12.99 Each Topping $0.70 $1.00 $1.50 Develop a C++ program that
Part 1: Pizza Price Calculator
Size | S (10") | M(13") | L(16") |
Base Price | $6.99 | $9.99 | $12.99 |
Each Topping | $0.70 | $1.00 | $1.50 |
Develop a C++ program that reads in the size of a pizza (S,M, or L) and the number of toppings, and then outputs the total price of the pizza on the screen. The price must be calculated based on the table above. For example, when a customer orders a pizza of size 'M' with three toppings, the total price is $9.99 + $1.00 x 3 = $12.99. The maximum number of toppings for one pizza is 5.
- Use three functions: one for input, one calculating, and one for output.
- pizzaOrder: gets the size and the number of toppings.
- Use call-by-reference to return two values back to main function.
- The size must be a character, S, M, or L.
- If user inputs characters other than S, M, or L, the program should prompt to input it again.
- The number of toppings ranges 0 to 5.
- If user inputs values out of the range, the program should prompt to input it again.
- calculatePizzaPrice: calculate the total price of the pizza.
- The price must be calculated based on the table above.
- displayPizzaPrice: outputs the total price , size of the number of toppings on the screen.
- Amounts in dollar should be formatted; show 2 digits of fraction part to represent the cent, like $12.99.
- State 'precondition' and 'postcondition' for each function in comment lines.
- Your functions should work with main function below.
- pizzaOrder: gets the size and the number of toppings.
- Include a loop that lets the user repeat this computation for new input values until the user wishes to end the program.
- This is implemented already. But you have to define askYesNo function. See below.
- Declare variables to express all constant values used in the code with the modifier const. And use them in your code.
- Use an appropriate data type for each variable and function.
- Hint : see Supermarket Pricing code here.
- State your name in a comment line.
int main(int argc, const char * argv[]) { do{ // get a pizza order char pizzaSize; int numberOfToppings; pizzaOrder(pizzaSize,numberOfToppings); // calculate the price double pizzaPrice = calculatePizzaPrice(pizzaSize,numberOfToppings); // print the price displayPizzaPrice(pizzaSize,numberOfToppings,pizzaPrice); std::cout << "Repeat? [Y/N]"; }while(askYesNo()); std::cout << "Bye "; return 0; }
in C ++
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started