I\'ve started this program, but I\'m just having a few issues. Here is the quest
ID: 3548605 • Letter: I
Question
I've started this program, but I'm just having a few issues. Here is the question:
Pennington Book Store wants an application that calculates and displays the total amount a customer owes. A customer can purchase one or more books at either the same or different prices. The application should keep a running total of the amount the customer owes, and display the total in the Total due box. For example, a customer might purhcase two books at $6 and three books at $10. To calculate the total due, the user will need to enter 2 in the Quantity box and 6 in the Price box, and then click the Add to Sale button. The total due box should display $42.00. Before calculating the next customer's order, the user will need to click the New Order button. Be sure to use a class in the application
Explanation / Answer
#include<iostream>
using namespace std;
class totalDueMoney{
int totalDue;
public:
totalDueMoney(){
totalDue = 0;
}
void addTotalDue(int amount){
totalDue+=amount;
}
void display(){
cout << "Total Due = " << totalDue << endl ;
}
int getTotalDue(){
return totalDue;
}
};
int main(){
totalDueMoney T1;
int choice = 0;
int noOfBox,price,amount;
while(choice != 4){
cout << "1.Place Order " << endl;
cout << "2.View Total Due" << endl;
cout << "3.Make Payment " << endl;
cout << "4.EXIT " << endl;
cin >> choice;
switch(choice){
case 1:
cout << "Enter number of boxes : ";
cin >> noOfBox;
cout << "Enter Price per book : ";
cin >> price;
amount = noOfBox*price;
T1.addTotalDue(amount);
break;
case 2:
T1.display();
break;
case 3:
cout << "Your bill is of " << T1.getTotalDue() << "$" << endl;
break;
case 4:
cout << "Thanks for using " << endl;
break;
default:
cout << "Enter valid option " << endl;
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.