0% found this document useful (0 votes)
23 views1 page

1

The document describes a class called Atransport that calculates shipping charges based on parcel weight. It defines methods to accept customer input, calculate charges based on weight tiers and surcharges, and print results.

Uploaded by

Ananya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views1 page

1

The document describes a class called Atransport that calculates shipping charges based on parcel weight. It defines methods to accept customer input, calculate charges based on weight tiers and surcharges, and print results.

Uploaded by

Ananya
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

class Atransport //start of method

{
String name;
int w,charge;
void accept() //start of method
{
Scanner sc=new Scanner(System.in); //start of scanner class
System.out.println("Enter name of the customer");
name=sc.nextLine();
System.out.println("Enter the weight of the parcel(in Kg)");
w=sc.nextInt;
}
void calculate() //start of calculate method
{
if(w>=1&&w<=10)
{
charge=w*25;
}
else if(w>10&&w<=30)
{
charge=250+(w-10)*20;
}
else if(w>20)
{
charge=650+(w-30)*10;
}
charge=charge+charge*0.05; //surcharge
}
void print()
{
System.out.println("Name weight bill amount");
System.out.println("name+","w+","+charge");
}
public static void main(String args[]) //start of main method
{
Atransport ob=new Atransport();
ob.accept();
ob.calculate();
ob.print();
}
}

You might also like