I am supposed to answer the following 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 no more than 6 Pounds : $2.20
Over 6 pounds but no 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 wrote this code:
import javax.swing.JOptionPane;
public class ShippingChargesLOL
{
public static void main( String[] args )
{
String input;
int weight;
double rate;
input = JOptionPane.showInputDialog("weight = ?");
weight = Integer.parseInt(input);
if (weight <= 2)
{
JOptionPane.showMessageDialog(null, rate = 1.1);
}
else if (weight <= 6)
{
JOptionPane.showMessageDialog(null, rate = 2.2);
}
else if (weight <=10)
{
JOptionPane.showMessageDialog(null, rate = 3.7);
}
else
{
JOptionPane.showMessageDialog(null, rate = 3.8);
}
System.exit(0);
}
}
I am not sure if i completely finished the program. The question talks about a package being shipped more than 500 miles but doesn't state that I need to ask the user for the miles that the package will need to be shipped. Did i finish the program correctly or am i missing something?
Message was edited by:
wksmdt
null