Goal: Design and build a simple cash register program in C++ using the programmi
ID: 3784416 • Letter: G
Question
Goal: Design and build a simple cash register program in C++ using the programming constructs included (simple expressions, a loop, and if statements). For the card pin, the person must be able to enter a four digit number ranging from 0000-9999, it must tell them there is an error if they enter less than 4 digits, more than 4 digits, or a negative number. Another check is that for the entering of prices, there needs to an error alert for the entry of negative numbers. The prices should be allowed to take any non negative number, ex: 3;3.5;333.33;14,536.12. Thank you.
Problem: A company needs a cash register program to work on their new computer system. The program should first ask whether the payment is in cash and credit card. If it is a credit card transaction, you must get the card pin. The program will then read in a number of prices to read, finally it must read in that many prices and compute the total. A discount is computed from the total at these rates:
$100 3% discount $1000 5% Discount $10,000 11% Discount
The amount of the discount is displayed if it is applicable. Taxes should be computed on the discounted total price at a 6% rate and the information should be displayed on the screen.
Explanation / Answer
#include<iostream>
#include<string>
int main()
{
string payment;
int pin=0, n;
double total=0, p, discount, tax;
cout <<"Enter C for cash payment or CC for Card Payment: ";
cin >>payment;
if(payment=="CC" || payment=="cc")
{
while(pin < 1001 || pin >10000)
{
cout <<"Please enter 4 digit PIN ";
cin >> pin;
if(pin > 1000 && pin < 10000)
break;
else cout <<"Wrong pin ";
}
}
cout <<"Please enter number of prices to enter ";
cin >>n;
for(int i=1;i<=n;i++)
{
cout <<"Please enter price "<<i<<": ";
cin >> p;
total=total+p;
}
if(total <=100)
discount = 0.03*total;
else if(total > 100 && total <= 1000)
discount = 0.05*total;
else if(total > 1000)
discount = 0.11*total;
cout << "Total is "<<total<<" Discount is "<< discount <<endl;
tax= 0.06*total;
cout <<"Tax payable: "<<tax<<" Final Total: "<<total-tax;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.