Write a program to accept the weight of the parcel and calculate the bill according the given price slabs.
Weight Rates per Kg
<=10Kg 30
Next 20 Kg 20
More than 30 kg 15
import java.io.*;
class charges
{
public static void main()throws IOException
{
BufferedReaderbr=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter a weight");
double kg=Double.parseDouble(br.readLine());
double charge=0.0;
if(kg<=10)
{
charge=kg*30;
}
else if((kg>10)&&(kg<=30))
{
charge=10*30;
charge=charge+(kg-10)*20;
}
else
{
charge=10*30;
charge=charge+(20*20)+(kg-30)*15;
}
System.out.println("The amount to be paid is"+charge+"Rs");
}
}
o/p Enter weight 5 The amount to be paid is150.0Rs |