The Fast Freight Shipping Company charges the following rates: Weight of Package
ID: 3767775 • Letter: T
Question
The Fast Freight Shipping Company charges the following rates:
Weight of Package Rate per 500 Miles Shipped
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
The shipping charges per 500 miles are not prorated. For example, if a 2-pound package is
shipped 550 miles, the charges would be $2.20. Write a program that asks the user to enter
the weight of a package and then displays the shipping charges.
I need it in java ;) thank you :)
Explanation / Answer
import java.util.Scanner;
public class charges
{
public static void main (String[] args)
{
int weight = 0;
double distance = 0.0;
double rate;
int distanceMultiplier = (int)distance / 500;
int distance;
Scanner input = new Scanner(System.in);
System.out.println("What is the weight of the package");
weight = input.nextInt();
System.out.println("What is the shipping distance");
distance = input.nextDouble();
distance = (int)distance % 500;
if (distance == 0)
{
if (weight <= 2)
System.out.println("Total Shipping Cost is: $ " + (distanceMultiplier * 1.10));
}
else if (weight > 2 && weight <= 6)
{
System.out.println("Total Shipping Cost is: $ " + (distanceMultiplier * 2.20));
}
else if (weight > 6 && weight <= 10)
{
System.out.println("Total Shipping Cost is: $ " + (distanceMultiplier * 3.70));
}
else
{
System.out.println("Total Shipping Cost is: $ " + (distanceMultiplier * 3.80));
}
if (distance != 0)
{
if (weight <= 2)
System.out.println("Total Shipping Cost is: $ " +(distanceMultiplier + 1) * 1.10);
}
else if (weight > 2 && weight <= 6)
{
System.out.println("Total Shipping Cost is: $ " +(distanceMultiplier + 1) * 2.20);
}
else if (weight > 6 && weight <= 10)
{
System.out.println("Total Shipping Cost is: $ " +(distanceMultiplier + 1) * 3.70);
}
else
{
System.out.println("Total Shipping Cost is: $ " +(distanceMultiplier + 1) * 3.80);
System.exit(0);
}
}
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.