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
Post A Comment:
0 comments: