Make a program that will compute the total
bill of the customer. The program will input
item purchased, quantity, price and cash
given by the customer. It will display the
total bill and the change of the customer if
the cash is greater than the total bill. If
the customer reaches 800 pesos, he/she will
avail 30% discount of his/her total bill.
Use if else statement and repetition structure
and display the "DO YOU WANT TO TRY AGAIN? Y/N?"
#include <iostream>
#include <string>
using namespace std;
void totalBill()
{
string item;
double quantity;
double price;
double cash;
double pay;
double discount{ 0 };
double change{ 0 };
double total_pay;
cout << "Enter the name of the purchased item: ";
cin >> item;
cout << "Enter the quantity of the purchased item:";
cin >> quantity;
cout << "Enter the unit price of the purchased item: ";
cin >> price;
cout << "Enter the amount of cash";
cin >> cash;
cout << "Check for purchased item:" << endl;
cout << "Purchased " << quantity << "units of " << item << endl;
pay = price * quantity;
cout << "Product price:" << pay<<endl;
if (pay > 800)
{
discount = pay * 0.3;
pay -= discount;
cout << "Discount:" << discount<<endl;
}
if (cash > pay)
{
change = cash - pay;
cout << "Change: " <<change<< endl;
}
cout << "Total product price:" << pay << endl;
}
int main()
{
string choise;
for (; ; )
{
totalBill();
cout << "DO YOU WANT TO TRY AGAIN ? Y / N ? ";
cin >> choise;
if (choise == "N" || choise == "n")
{
break;
}
}
return 0;
}
Comments
Leave a comment