All Type Coding

Search Here

How do I accept a price from user,if the price money is less than equal to Rs.5000 then no discount is available ,if price is greater than Rs.5000 and less than equal to Rs.10000 then discount is 5%, if price is greater than Rs.10000 and less than equal to Rs.15000 then discount is 10% and if price is greater than Rs.15000 and less than equal to Rs.20000 then discount is 15% and for more than Rs.20000 shopping ,discount is 20%,now find the discounted money and amount payable by user in c #.?

using System;

class abc
{
float price,discount,total;
public void fun()
{

Console.WriteLine("Enter the price : ");
price=Convert.ToSingle(Console.ReadLine());

if(price<=5000)
{
Console.WriteLine("There is no discount ");

}
else if(price>5000 && price<=10000)
{
Console.WriteLine("Discount is 5% ");
discount=(price*5)/100;
Console.WriteLine("Your discounted amount is : "+discount);
}
else if(price>10000 && price<=15000)
{
Console.WriteLine("Discount is 10%");
discount=(price*10)/100;
Console.WriteLine("Your discounted amount is : "+discount);
}
else if(price>15000 && price<=20000)
{
Console.WriteLine("Discount is 15% ");
discount=(price*15)/100;
Console.WriteLine("Your discounted amount is : "+discount);
}
else
{
Console.WriteLine("Discount is 20% ");
discount=(price*20)/100;
Console.WriteLine("Your discounted amount is : "+discount);
}
total=(price-discount);
Console.WriteLine("Amount payable by user is : "+ total);
Console.ReadKey();
}

}

class price
{
public static void Main(string []args)
{
abc a1=new abc();
a1.fun();
}

}
Output :


No comments :

Post a Comment