Computer Science, asked by rinachourasia297, 9 months ago

A courier company charges differently for 'Ordinary' booking and 'Express' booking
based on the weight of the parcel as per the tariff given below:
Ordinary booking
80
Weight of parcel
Up to 100 gm
101 to 500 gm
501 gm to 1000 gm
More than 1000 gm
Express booking
100
200
150
210
* 250
250
300
Write a program to input weight of a parcel and type of booking (O for ordinary and
'E' for express). Calculate and print the charges accordingly.​

Attachments:

Answers

Answered by parthpawarcool24
20

Answer:

import java.util.*;

public class parcel

{

   public static void main(String args[])

   {

       Scanner in = new Scanner(System.in);

       int charge = 0;

       System.out.println("Enter the type of booking you want");

       System.out.println("1. Ordinary Booking");

       System.out.println("2. Express Booking");

       System.out.println("Press 'O' for Ordinary booking, and press 'E' for Express booking");

       String c = in.next();

       System.out.println("Enter the wieght of the parcel");

       int wt = in.nextInt();

       if("O".equals(c))

       {

           System.out.println("You have choosen ordinary booking for your package");

           if(wt<=100)

           charge=charge+80;

           if(wt>100 && wt<=500)

           charge=charge+150;

           if(wt>500 && wt<=1000)

           charge=charge+210;

           if(wt>1000)

           charge=charge+250;

           System.out.println("Wieght of the parcel is "+wt);

           System.out.println("Charge to be paid is Rs."+charge);

       }

       else if("E".equals(c))

       {

           System.out.println("You have choosen express booking for your package");

           if(wt<=100)

           charge=charge+100;

           if(wt>100 && wt<=500)

           charge=charge+200;

           if(wt>500 && wt<=1000)

           charge=charge+250;

           if(wt>1000)

           charge=charge+300;

           System.out.println("Wieght of the parcel is "+wt);

           System.out.println("Charge to be paid is Rs."+charge);

       }

       else

       {

           System.out.println("Invalid choice");

       }

   }

}

Explanation:

Similar questions