write a java program.a courier company charges for an ordinary mail and an express mail based on the weight of the parcel as per tariff given below: wgt of parcel(in.gms) 1)upto 100gms 2)101 to 500 gms 3)501 and above charge on ordinary mail 1)rs 50 2)rs 40/100 gms 3)rs 35/100gms charge on express mail 1)rs 80 2)rs 70/100gms 3)rs 65/100gms
dont spamm
Answers
Answer
4.0/5
1
Ari114
Expert
330 answers
10.9K people helped
Answer:
hello bro just look and like it
Explanation:
import java.util.Scanner;
public class gdrmm
{
public static void main(String args[])
{
int wt,charge,unit=0;
char type;
Scanner in = new Scanner(System.in);
System.out.print("Enter weight of parcel: ");
wt = in.nextInt();
System.out.print("Enter type of booking: ");
type = in.next().charAt(0);
charge = 0;
if(type == 'O')
{
if(wt<=100)
charge=50;
else if(wt>100 && wt<=500)
{ unit =(int)( Math.ceil(wt/100.0));
charge=unit*40;
}
else if(wt>=501 && wt<=1000)
{ unit = (int)(Math.ceil(wt/100.0));
charge=unit*35;
}
}
if(type == 'E')
{
if(wt<=100)
charge=80;
else if(wt>100 && wt<=500)
{ unit = (int)(Math.ceil(wt/100.0));
charge=unit*70;
}
else if(wt>=501 && wt<=1000)
{ unit = (int)(Math.ceil(wt/100.0));
charge=unit*65;
}
}
System.out.print("The type of percel is ; " + type);
System.out.print("The weight of percel is ; " + wt+" gr .");
System.out.print("The type of percel is ; " + charge+" /-");
}
}