A cloth showroom has announced the following festival discounts on the purchase of items, based on the total cost of the items buyed. Total cost Discounts (in percentage) Less than Rs.2000 5% Rs.2001 to Rs.5000 25% Rs.5001 to Rs.10000 35% Above Rs.10000 50%
A cloth showroom has announced the following festival discounts on the purchase of items, based on the total cost of the items buyed.
Total cost Discounts (in percentage)
Less than Rs.2000 5% Rs.2001 to Rs.5000 25%
Rs.5001 to Rs.10000 35%
Above Rs.10000 50%
-------------------------------------------------------------------------------------------------
import java.util.*;
class Showroom
{
static double totcost,netamt,disc;
public static void work()
{
Scanner Sc=new Scanner(System.in); System.out.println(“Enter the total cost”);
totcost =Sc.nextDouble();
{
if(totcost<2000)
{ disc =0.05*totcost; }
if(totcost>=2001&&totcost<=5000)
{ disc=0.25*totcost;}
if(totcost>=5001&&totcost<=10000)
{
disc=0.35*totcost; } if(totcost>10000)
{
disc=0.50*totcost;
}
netamt=totcost-disc;
{
System.out.println(“Total cost “+totcost);
}
{
System.out.println(“Discount given:”+dis);
}
{ System.out.println(“Net amount “+netamt);
} } }
public static void main()
{
Showroom1=newShowroom1();
obj.work();
} } }
Output: Enter
the total cost 20000 {
static double totcost,netamt,disc;
public static void work()
{
Scanner Sc=new Scanner(System.in); System.out.println(“Enter the total cost”);
totcost =Sc.nextDouble();
{
if(totcost<2000)
{ disc =0.05*totcost; }
if(totcost>=2001&&totcost<=5000)
{ disc=0.25*totcost;}
if(totcost>=5001&&totcost<=10000)
{
disc=0.35*totcost; } if(totcost>10000)
{
disc=0.50*totcost;
}
netamt=totcost-disc;
{
System.out.println(“Total cost “+totcost);
}
{
System.out.println(“Discount given:”+dis);
}
{ System.out.println(“Net amount “+netamt);
} } }
public static void main()
{
Showroom1=newShowroom1();
obj.work();
} } }
Total cost 20000
Discount given 10000
Net amount 10000
------------------------------------------------------------------------------------------------------------------
Just copy paste the code into the class file of Bluej compiler. Change the class name according to your's.
I hope now you can do the coding of " A cloth showroom has announced the following festival discounts.......
Thanks for visting Programming in JAVA
Happy Coding !!
THANKS 😃
ReplyDeleteYou're welcome.
Delete