Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

Problem with finishing a C++ code.

$
0
0
Here is the problem:

I just need help with the underlined and purple part:

The C++ Side Restaurant wants you to write a program that simulates a simple cash register. The program should ask the user if a customer is to be processed. If the user responds yes, the program prompts the user to enter the price of the meal. Then the program calculates the sales tax (8.25% of the meal price) and the total price, which it should display to the user. Next, the program asks the user to enter the amount tendered, and displays the amount tendered, the total price, and the customer’s change. The program then asks the user if there is another customer to process. If the user responds yes, the program processes the next customer in the same way. This procedure continues indefinitely until the user responds no to the prompt for another customer. Finally, the program displays the total number of customers it processed and the grand total of all the meal prices.

I just need help with the underlined part. I finished the code but didn't see that last part. I know I need to use a x++ increment operator somehow, but I know know how to add up all the total. Im not sure where to put the increment operator eith.


Here is my code:

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

int main ()
{
// Variables
double change, total, amount_tendered, price_meal, tax;
double SALES_TAX=.0825;
char choice, start_choice ;


cout << "       ******The C++ Side Restaurant******" << endl << endl;
cout << "Would you like to process a transaction? (Y/N) ";
cin >> start_choice;
if ( start_choice == 'y' || start_choice == 'Y' )
{
do
{
	cout << " \nPrice of the meal $ ";
	cin >> price_meal;
	tax = SALES_TAX * price_meal;
	total = price_meal + tax;

	cout << setprecision(2) << fixed;
	cout << " \nSales tax $ " << tax << endl << endl;
	cout << "Total amount $ " << total << endl;

	
	cout << "\nAmount tendered:" ;
	cin >> amount_tendered;

	if (amount_tendered>total)
	{
		cout << setprecision(2) << fixed;
		change = amount_tendered-total;
		cout << " \nChange $ " << change << endl;
	}
	else if (amount_tendered < total)
	{
		cout << " \nError: Amount tendered should be more than the total bill " << endl;
	}
	else if (amount_tendered == total)
	{
		cout << "\nChange $ 0.00" << endl;
	}

	cout << "\n\nDo you want to process another transaction? (Y/N) ";
	cin >> choice;
} while (choice == 'Y' || choice == 'y');
cout << "\nProgram Ending" << endl << endl;

}
else 
	cout << "\nProgram Ending" << endl << endl;


return 0;
}


Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>