Project 1: CorsairBurger Calculator Write a C++ program that calculates costs fo
ID: 671728 • Letter: P
Question
Project 1: CorsairBurger Calculator Write a C++ program that calculates costs for a new food service provider, CorsairBurger. Meal prices are based on the type of burger ordered ($2.00 for a plain burger, $2.50 for a cheeseburger, $4.00 for a double burger and $5.00 for a double burger with cheese), whether fries and a drink are desired ($2 more for fries and a drink), Total meal charges will get discounted based on large parties (5% reduction for ten or more burgers ordered), and whether the diner is an SMC student ($0.50 reduction per burger ordered). Be sure to add 8.25% sales tax to get the total bill. Be sure your program does not allow negative data or for the number of fries and drinks ordered to exceed the number of burgers ordered. The sample program dialogs below should help you to see how to perform this calculation. IN ORDER TO RECEIVE FULL CREDIT, YOU NEED TO DECLARE AND USE ATLEAST ONE const DECLARATION FOR SOME CERTAIN VALUES IN YOUR PROGRAM. CorsairBurger Meal Calculator Enter the number of burgers you want:-20 Sorry Charlie! Continue(y/n)? y Enter the number of burgers you want:1 Enter the number of cheeseburgers you want:-20 Sorry Charlie! Continue(y/n)? y Enter the number of burgers you want:1 Enter the number of cheeseburgers you want:0 Enter the number of double burgers you want:-20 Sorry Charlie! Continue(y/n)? y Enter the number of burgers you want:1 Enter the number of cheeseburgers you want:0 Enter the number of double burgers you want:0 Enter the number of double burgers with cheese you want:-20 Sorry Charlie! Continue(y/n)? y Enter the number of burgers you want:1 Enter the number of cheeseburgers you want:0 Enter the number of double burgers you want:0 Enter the number of double burgers with cheese you want:0 SMC Student diner discount with each burger? [1=YES/0=NO]:0 How many fries and drinks you want with your order? 20 Sorry Charlie! CorsairBurger Meal Calculator Enter the number of burgers you want:1 Enter the number of cheeseburgers you want:0 Enter the number of double burgers you want:0 Enter the number of double burgers with cheese you want:0 SMC Student diner discount with each burger? [1=YES/0=NO]:0 How many fries and drinks you want with your order? 0 Meal Cost: $ 2.00 Reductions: $ 0.00 Sales Tax: $ 0.17 Total Cost: $ 2.17 Continue(y/n)? y Enter the number of burgers you want:3 Enter the number of cheeseburgers you want:3 Enter the number of double burgers you want:3 Enter the number of double burgers with cheese you want:3 SMC Student diner discount with each burger? [1=YES/0=NO]:1 How many fries and drinks you want with your order? 12 Meal Cost: $ 64.50 Reductions: $ 9.23 Sales Tax: $ 4.56 Total Cost: $ 59.83 Continue(y/n)? y Enter the number of burgers you want:1 Enter the number of cheeseburgers you want:1 Enter the number of double burgers you want:1 Enter the number of double burgers with cheese you want:1 SMC Student diner discount with each burger? [1=YES/0=NO]:1 How many fries and drinks you want with your order? 4 Meal Cost: $ 21.50 Reductions: $ 2.00 Sales Tax: $ 1.61 Total Cost: $ 21.11 Continue(y/n)? n
Explanation / Answer
#include <iostream>
using namespace std;
int main(){
while(true){
int burgers, cheeseBurgers, doubleBurgers, doubleCheeseBurgers, fries, totalBurgers = 0;
int discount, reductions = 0, tax = 0, totalCost = 0;
double cost = 0;
char more;
cout << "CorsairBurger Meal Calculator ";
do{
cout << "Enter the number of burgers you want: ";
cin >> burgers;
if(burgers < 0){
cout << "Sorry Charlie! ";
break;
}
else totalBurgers += burgers;
cost += burgers * 2;
}while(burgers < 0);
if(burgers < 0){
cout << "Continue(y/n)? ";
cin >> more;
if(more == 'n') break;
else continue;
}
do{
cout << "Enter the number of cheeseburgers you want: ";
cin >> cheeseBurgers;
if(cheeseBurgers < 0){
cout << "Sorry Charlie! ";
break;
}
else totalBurgers += cheeseBurgers;
cost += cheeseBurgers * 2.5;
}while(cheeseBurgers < 0);
if(cheeseBurgers < 0){
cout << "Continue(y/n)? ";
cin >> more;
if(more == 'n') break;
else continue;
}
do{
cout << "Enter the number of double burgers you want: ";
cin >> doubleBurgers;
if(doubleBurgers < 0) cout << "Sorry Charlie! ";
else totalBurgers += doubleBurgers;
cost += doubleBurgers * 4;
}while(doubleBurgers < 0);
if(doubleBurgers < 0){
cout << "Continue(y/n)? ";
cin >> more;
if(more == 'n') break;
else continue;
}
do{
cout << "Enter the number of double burgers with cheese you want: ";
cin >> doubleCheeseBurgers;
if(doubleCheeseBurgers < 0) cout << "Sorry Charlie! ";
else totalBurgers += doubleCheeseBurgers;
cost += doubleCheeseBurgers * 5;
}while(doubleCheeseBurgers < 0);
if(doubleCheeseBurgers < 0){
cout << "Continue(y/n)? ";
cin >> more;
if(more == 'n') break;
else continue;
}
cout << "SMC Student diner discount with each burger? [1=YES/0=NO]: ";
cin >> discount;
reductions += discount * totalBurgers * 0.5;
do{
cout << "How many fries and drinks you want with your order? ";
cin >> fries;
if(fries > totalBurgers) cout << "Sorry Charlie! ";
}while(fries > totalBurgers);
totalCost = cost - reductions;
totalCost += fries * 2;
totalCost += 0.0825 * totalCost;
cout << "Meal Cost: $" << totalCost << " Reductions: $" << reductions << " Sales Tax: $" << tax << " Total Cost: $" << totalCost << " ";
cout << "Continue(y/n)? ";
cin >> more;
if(more == 'n') break;
else continue;
}
}
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.