Answer to Question #181086 in C++ for Qwerty

Question #181086

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?"


1
Expert's answer
2021-04-13T20:07:02-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS