Tax Calculation Using Switch Case in Java
Tax Calculation Using Switch Case in Java
import java.io.*;
class shop
int ch,num;
float price;
double tax,bill;
try
ch=Integer.parseInt(dts.readLine());
switch (ch)
case 1:
price=Float.parseFloat(dts.readLine());
num=Integer.parseInt(dts.readLine());
tax=((price*num)*8)/100;
bill=Math.round((price*num)+tax);
System.out.println("******************");
System.out.println("The bill for motor(s) are :"+bill);
break;
case 2:
price=Float.parseFloat(dts.readLine());
num=Integer.parseInt(dts.readLine());
tax=((price*num)*12)/100;
bill=Math.round((price*num)+tax);
System.out.println("************************");
break;
case 3:
price=Float.parseFloat(dts.readLine());
num=Integer.parseInt(dts.readLine());
tax=((price*num)*5)/100;
bill=Math.round((price*num)+tax);
System.out.println("******************************");
break;
case 4:
num=Integer.parseInt(dts.readLine());
tax=((price*num)*7.5)/100;
bill=Math.round((price*num)+tax);
System.out.println("***************************");
break;
case 5:
price=Float.parseFloat(dts.readLine());
num=Integer.parseInt(dts.readLine());
tax=((price*num)*3)/100;
bill=Math.round((price*num)+tax);
System.out.println("*************************");
break;
default:
catch(Exception e)
System.out.println(e.getMessage());
}
System.out.println("***************************************");
System.out.println("***************************************");