Write a C++ program to calculate the total expenses if quantity and price per item are input by the user and discount of 20% is offered if the expense is more than 10000.  

Program Code:
#include<iostream>
using namespace std;
int main()
{

int total_expenses, quantity, price, discount;
cout<<"Enter total quantity to be purchased  :";
cin>>quantity;
cout<<endl;
cout<<"Enter price of total quantity purchased  :";
cin>>price;
cout<<endl;
total_expenses = quantity * price;
if(total_expenses>10000)
{
discount=(total_expenses*0.2);
total_expenses=total_expenses-discount;
}
cout<<"Total Expense is  Rs. "<<total_expenses;
return 0;
}


The program output is tested on www.jdoodle.com
Output:
Enter total quantity to be purchased : 10
Enter price of total quantity purchased : 15000
Total Expense is  Rs. 120000


Thanks
Mukesh Rajput


Mukesh Rajput

Mukesh Rajput

I am a Computer Engineer, a small amount of the programming tips as it’s my hobby, I love to travel and meet people so little about travel, a fashion lover and love to eat food, I am investing a good time to keep the body fit so little about fitness also..

Post A Comment:

0 comments: