While purchasing certain items, a discount of 10% is offered if the quantity purchased is more than 1000. If quantity and price per item are input through the keyboard, write a C++ program to calculate the total expenses.

/* While purchasing certain items, a discount of 10% is offered if the quantity purchased is more than 1000. If quantity and price per item are input through the keyboard, write a C++ program to calculate the total expenses. */
#include <iostream>
using namespace std;
int main() 
{
	int qty, dis = 0;
	float rate, expense;

	cout << "Enter Quantity: ";
	cin >> qty;

	cout << "Enter Rate: ";
	cin >> rate;

	if (qty>1000)
		dis = 10;
	expense= (qty*rate) - (qty*rate*dis / 100);
	cout << "\nTotal Expenses = Rs. " << expense;
    return 0;
}

Output :
Enter Quantity: 200
Enter Rate: 100

Total Expenses = Rs. 20000



Leave a comment