Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

A local restaurant, ZyBurger, charges $1.49 for burgers, $0.89 for fries, and $0

ID: 3807222 • Letter: A

Question

A local restaurant, ZyBurger, charges $1.49 for burgers, $0.89 for fries, and $0.99 for sodas.

Write a program that allows an employee to enter an order consisting of the number of burgers, fries, sodas, and a name for the order. Then display the total, the tax (at 6%), and the grand total. Next, the program will allow the employee to enter the amount tendered, and then display the change. Finally, the program will display the order name and the order number.

Note: This zyLab outputs a newline after each user-input prompt. For convenience in the examples below, the user's input value is shown on the next line, but such values don't actually appear as output when the program runs. This lab also deals with the representation of currency values. We have not covered how to display 0's as place holders, so it is expected that "$20.50" will display as 20.5

(1) Prompt the user to input the number of burgers, fries, sodas, and a name for the order. Calculate and output the subtotal. The item counts should be stored in int variables, while the name should be stored in a string. The subtotal should be stored in a double and when displayed shown to two decimal places. (2 pts)

*There is an issue that can occur when using cins and getlines in a program. If you were using all cins or all getlines, there is issue does occur. It only happens when you program has both methods of input. *

Check out the following link: https://mathbits.com/MathBits/CompSci/APstrings/APgetline.htm

2) Extend to also calculate the meal tax (%6) and the grand total. The tax rate should be stored as a decimal number in a const double variable. The tax and grandtotals should be stored in double variables and when displayed shown to two decimal places. (2pts)

3) Extend to prompt the user for the amount tendered. Calculate and display the change due. Both the amount tendered and the change due should be stored in double variables. (2 pts)

4) Extend to display the customers name and their order number. For the order number, calculate a random # between 1 - 999 (inclusive). The order number should be stored in an int.

In my code I am keep getting error and i am only getting 4/8

I cannot figureout my error.

#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {

double burgers = 1.49;
double fries = 0.89;
double sodas = 0.99;
double subTotal, numTax, grandTotal;
int numBurgers, numFries, numSodas, randNum, orderNum;
string fName = " ";
//string lName = " ";

cout << "Enter the number of burgers:" << endl;
cin >> numBurgers;
cout<< "Enter the number of fries:" << endl;
cin >> numFries;
cout << "Enter the number of sodas:" << endl;
cin >> numSodas;
cout << "Please enter the name for the order:" << endl;
cin >> fName;
// cout << "Please enter the last name for the order:" << endl;
// cin >> lName;
cout << " ";



subTotal = (numBurgers * burgers) + (numFries * fries) + (numSodas * sodas);
cout << "The subtotal is: " << "$" <<subTotal << endl;

numTax = (subTotal * 6) / 100;
cout << "The meal tax is: " << "$" <<numTax << endl;
cout << "--------------------------" << endl;
grandTotal = subTotal + numTax;
cout << "The grand total is: " << "$" << grandTotal << endl;

cout << " ";
double change, tendered;
cout << "Please enter the amount tendered:" << endl;
cin >> tendered;
change = grandTotal- tendered ;
cout << " ";

std::cout << std::fixed;
std::cout << std::setprecision(0);
std::cout << "The change due to the customer is:"<<"$" << change;
randNum = rand () % 1000;
cout << "Order Number:" <<" #";
cin>> orderNum;


  
return 0;
}

Explanation / Answer

#include <iostream>
#include <string>
#include <cmath>
#include <iomanip>
using namespace std;

int main() {

double burgers = 1.49;
double fries = 0.89;
double sodas = 0.99;
double subTotal, numTax, grandTotal;
int numBurgers, numFries, numSodas, randNum, orderNum;
string fName = " ";
//string lName = " ";

cout << "Enter the number of burgers:" << endl;
cin >> numBurgers;
cout<< "Enter the number of fries:" << endl;
cin >> numFries;
cout << "Enter the number of sodas:" << endl;
cin >> numSodas;
cout << "Please enter the name for the order:" << endl;
cin >> fName;
// cout << "Please enter the last name for the order:" << endl;
// cin >> lName;
cout << " ";



subTotal = (numBurgers * burgers) + (numFries * fries) + (numSodas * sodas);
cout << "The subtotal is: " << "$" <<subTotal << endl;

numTax = (subTotal * 6) / 100;
cout << "The meal tax is: " << "$" <<numTax << endl;
cout << "--------------------------" << endl;
grandTotal = subTotal + numTax;
cout << "The grand total is: " << "$" << grandTotal << endl;

cout << " ";
double change, tendered;
cout << "Please enter the amount tendered:" << endl;
cin >> tendered;
change = grandTotal- tendered ;
cout << " ";

std::cout << std::fixed;
std::cout << std::setprecision(0);
std::cout << "The change due to the customer is:"<<"$" << change;
randNum = rand () % 1000;
cout << "Order Number:" <<" #";
cin>> orderNum;


  
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote