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.
1
Expert's answer
2012-04-20T07:22:18-0400
#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) ";
Comments
Leave a comment