Tax Calculation using Switch Case in java
import [Link].*;
class shop
public static void main(String arg[])
int ch,num;
float price;
double tax,bill;
DataInputStream dts=new DataInputStream([Link]);
[Link]("Please enter your choice to buy an appliance;");
[Link]("1. Motor\n2. Fan\n3. Tubelight\n4. Wires\n5. Other”);
try
ch=[Link]([Link]());
switch (ch)
case 1:
[Link]("Please enter price for motor:");
price=[Link]([Link]());
[Link]("Enter no. of motor(s) you want to buy:");
num=[Link]([Link]());
tax=((price*num)*8)/100;
bill=[Link]((price*num)+tax);
[Link]("******************");
[Link]("The bill for motor(s) are :"+bill);
break;
case 2:
[Link]("Please enter price for fan:");
price=[Link]([Link]());
[Link]("Enter no. of fan(s) you want to buy:");
num=[Link]([Link]());
tax=((price*num)*12)/100;
bill=[Link]((price*num)+tax);
[Link]("************************");
[Link]("The bill for motor(s) are :"+bill);
break;
case 3:
[Link]("Please enter price for tubelight:");
price=[Link]([Link]());
[Link]("Enter no. of tubelight(ss) you want to buy:");
num=[Link]([Link]());
tax=((price*num)*5)/100;
bill=[Link]((price*num)+tax);
[Link]("******************************");
[Link]("The bill for tubelight(s) are :"+bill);
break;
case 4:
[Link]("Please enter price for wires:");
price=[Link]([Link]());
[Link]("Enter no. of wires you want to buy:");
num=[Link]([Link]());
tax=((price*num)*7.5)/100;
bill=[Link]((price*num)+tax);
[Link]("***************************");
[Link]("The bill for wire(s) are :"+bill);
break;
case 5:
[Link]("Please enter price for others:");
price=[Link]([Link]());
[Link]("Enter no. of others you want to buy:");
num=[Link]([Link]());
tax=((price*num)*3)/100;
bill=[Link]((price*num)+tax);
[Link]("*************************");
[Link]("The bill for other(s) are :"+bill);
break;
default:
[Link]("Sorry no such item");
catch(Exception e)
[Link]([Link]());
}
[Link]("***************************************");
[Link]("*********Thanks for your visit*********");
[Link]("***************************************");