The Fast Freight Shipping Company charges the following rates: Weight of Package
ID: 3764803 • Letter: T
Question
The Fast Freight Shipping Company charges the following rates: Weight of Package Rate per Pound 2 pounds or less $1.10 Over 2 pounds but not more than 6 pounds $2.20 Over 6 pounds but not more than 10 pounds $3.70 Over 10 pounds $3.80 Design a program (java language) that asks the user to enter the weight of a package and then displays the shipping charges (Must print out the table from the problem and format using printf)
I was given this code but when I tried to compile it it showed errors
public class FastFreightCharges
{
public static void main(String[] args)
{
System.out.printf("The FastFreightShipping Charges Table/n:");
System.out.printf("--------------------------------------------------------------");
System.out.printf("weight<=2 charges=1.10perpound/n");
System.out.printf("weight>2 and<=6 charges=2.20perpound/n");
System.out.printf("weight>6 and<=10 charges=3.70perpound/n");
System.out.printf("weight>10 charges=3.80perpound/n");
System.out.printf(""you entered wrong weight/n");
System.out.printf("------------------------------------------------------------");
System.out.printf("the weight of package:/n");
int no=Integer.ParseInt(args[0]);
if(no<=2)
{
System.out.printf("charges for package is",+(no*1.10));
}
else if(no>2&&no<=6)
{
System.out.printf("charges for you package is:",+(no*2.20));
}
else if(no>6&&no<=10)
{
System.out.printf("charges for your package is:",+(no*3.70));
}
else if(no>10)
{
Explanation / Answer
public class FastFreightCharges
{
public static void main(String[] args)
{
System.out.printf("The FastFreightShipping Charges Table :");
System.out.printf("-------------------------------------------------------------- ");
System.out.printf("weight<=2 charges=1.10perpound ");
System.out.printf("weight>2 and<=6 charges=2.20perpound ");
System.out.printf("weight>6 and<=10 charges=3.70perpound ");
System.out.printf("weight>10 charges=3.80perpound ");
System.out.printf("------------------------------------------------------------ ");
System.out.printf("the weight of package: ");
int no=Integer.parseInt(args[0]);
if(no<=2)
{
System.out.println("charges for package is"+(no*1.10));
}
else if(no>2&&no<=6)
{
System.out.println("charges for you package is:"+(no*2.20));
}
else if(no>6&&no<=10)
{
System.out.println("charges for your package is:"+(no*3.70));
}
else if(no>10)
{
System.out.println("charges for your package is:"+(no*3.80));
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.