Calculate the courier charges
Write a program to accept the weight of the parcel and calculate the bill according the given price slabs.
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");
}
}<tbody>
o/p Enter weight 5
The amount to be paid is150.0Rs
</tbody>
Related Posts
Continue learning with these related articles

String Methods in Java for ICSE Class 10: 25 Output Questions with Answers
ICSE Class 10 Computer Applications practice on String class methods: length, charAt, indexOf, lastIndexOf, substring, replace, trim, compareTo, equals and more, with 25 board-style output questions and step-by-step answers.

Special Number Programs in Java for ICSE: Armstrong, Spy, Neon, Disarium, Pronic and More
Every special number asked in ICSE Computer Applications – prime, perfect, Armstrong, palindrome, automorphic, neon, spy, Niven, duck, buzz, Disarium, special and pronic numbers – with definitions, examples and one complete Java program that checks them all.

Math Library Methods in Java for ICSE Class 9 (with Outputs)
ICSE Class 9 Computer Applications notes on the Java Math class: sqrt, cbrt, pow, abs, max, min, ceil, floor, round, rint and random, with return types, tricky negative-number outputs and Java expressions for formulas.