To calculate the shipping cost figure the shipping rate


The You Send It We Rend It Shipping Company charges the following shipping costs to ship packages:

Weight of Package (in pounds) Rate Per 100 miles (or partial 100 miles) shipped

From 1 lb up to and including 10 lbs $ 5.01 From 11 lbs up to and including 20 lbs $ 7.02 From 21 lbs up to and including 30 lbs $ 9.03 From 31 lbs up to and including 40 lbs $ 11.04 From 41 lbs up to and including 60 lbs $ 15.00

Write a program that asks for the weight of a package in pounds and then the distance the package is to be shipped. With this information, calculate and display the shipping charges for that package.

You may assume that all distances and weights will be integer values. You may not assume, however, that the values the user enters are valid. Because of this, your program will need to validate that the weight they enter is between 1 and 60, inclusive. The company can only ship packages between 1 pound and 60 pounds, inclusive (make sure that you allow for 1 and 60).

Once a valid weight has been obtained, your program will need to prompt the user for a valid distance until they enter a value greater than or equal to 1. The company has to ship a package at least 1 mile.

Output your results with two significant digits after the decimal place.

To calculate the shipping cost, figure the shipping rate based on the weight, then use the number of miles to calculate the actual shipping cost.

For example, for a package that weighs 22 pounds that is being shipped 297 miles, you should charge the individual $27.09 because: you should charge $9.03 (based on the weight) for the first 100 miles, $9.03 for the second 100 miles and another $9.03 for the remaining 97 miles, which is a fraction of 100 miles. Do not pro-rate the shipping charges based on partial mileage (like 97/100 miles).

-----------------------------------------------------------------------

This is what I have so far, I'm lost!

import java.util.Scanner;

public class psingh_Shipping
{
public static void main(String args[])
{
int weight = 0;
int distance;
Scanner in=new Scanner(System.in);

System.out.println("Welcome to the You Send It We Rend It Shipping Company");

System.out.print("How heavy is your package in pounds (1-60)? ");
weight=in.nextInt();

while(weight <= 0 || weight > 60)
{
System.out.print("How heavy is your package in pounds (1-60)? ");
weight=in.nextInt();
}

if(distance > 0)
{
System.out.print("%d\n", n);
distance=in.nextInt();uj
}

/*if(weight<11) price = distance*5.01;
else if (weight<21) price = distance*7.02;
else if (weight<31) price = distance*9.03;
else if (weight<41) price = distance*11.04;
else price = distance*15;

System.out.println("How far will you be shipping the package in miles? ");

System.out.println("Your total shipping cost for miles is tiny_mce_markerquot; + price);*/
}
}

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: To calculate the shipping cost figure the shipping rate
Reference No:- TGS02922465

Expected delivery within 24 Hours