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. */
using System;
public class Demo
{
    public static void Main(string[] args)
    {
        int qty, dis = 0;
        float rate, expense;

        Console.WriteLine("Enter Quantity: ");
        qty = Convert.ToInt32(Console.ReadLine());

        Console.WriteLine("Enter Rate: ");
        rate = float.Parse(Console.ReadLine());

        if(qty > 1000)
            dis = 10;
        expense = (qty * rate) - (qty * rate * dis / 100);
        Console.WriteLine("\nTotal Expenses = Rs. {0}", expense);
        Console.ReadLine();
    }
}

Output :
Enter Quantity:
20
Enter Rate:
120

Total Expenses = Rs. 2400



Leave a comment