62 568
Assignments Done
99%
Successfully Done
In June 2018

Answer to Question #8617 in C++ for marissa

Question #8617
Take quantity and price from the user.
Calculate the total payment ( payment = quantity * price ).
Display the quantity, price and payment.
Repeat the program as long as the user key in ‘1’.
Use while loop for this question.
Expert's answer
#include <iostream>

#include <conio.h>

using namespace std;




int main(int argc, char *argv[])

{

int quantity = 0;

int price = 0;

int payment = 0;// = quantity * price

char ch = '1';




//Repeat the program as long as the user key in ‘1’.

while(ch == '1')

{

cout << endl;

cout << "Enter Quantity:";

cin >> quantity;




cout << "Enter Price:";

cin >> price;




//Display the quantity, price and payment.

payment = quantity * price;

cout << "Quantity: "
<< quantity << endl;

cout << "Price: "
<< price << endl;

cout << "Payment: "
<< payment << endl << endl;

cout << "Do You want repeat?(press '1' to continue) ";

quantity = 0;

price = 0;

payment = 0;

ch =_getch ();

}

return 1;

}

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 first!

Leave a comment

Ask Your question

Submit
Privacy policy Terms and Conditions