Hanmu
02-27-2011, 03:54 PM
I'm having a little trouble figuring this program out. Now before I post the problem keep in mind this is my first CSC class and we are in the [I]if[I] statement so bare with me. The problem is as follows:
Shipping Charges
Weight of Package Rate Per 500 Miles Shipped
2 lbs or less $1.10
over 2lbs but no more than 6lbs $2.20
over 6lbs but no more than 10lbs $3.70
over 10lbs $3.80
The Shipping charges are not prorated so even if the pounds go over (0.5, for example) the price is doubled. So a 2 pound package traveling 550 would be $2.20. I have to write a program asking the user to enter the shipping miles and the weight and then displays the shipping charges.
I am using the JOptionPane method and this is what I have so far, but the distance is wrecking me, I can't calculate how to get the charge for the distance.
import javax.swing.JOptionPane;
public class shippingcharges
{
public static void main (String [] args)
{
double pounds,ship,m_1,m_2,m_3,m_4,distance;
String input;
input=JOptionPane.showInputDialog("Enter shpping distance");
ship=Double.parseDouble(input);
distance=ship%500;
input=JOptionPane.showInputDialog("Enter the weight");
pounds=Double.parseDouble(input);
if (pounds <=2)
JOptionPane.showMessageDialog(null,"Your shipping cost is "+m_1);
else
if (pounds >2)
JOptionPane.showMessageDialog(null,"Your shipping cost is ");
}
}
any suggestions???
Thank you:confused:
Shipping Charges
Weight of Package Rate Per 500 Miles Shipped
2 lbs or less $1.10
over 2lbs but no more than 6lbs $2.20
over 6lbs but no more than 10lbs $3.70
over 10lbs $3.80
The Shipping charges are not prorated so even if the pounds go over (0.5, for example) the price is doubled. So a 2 pound package traveling 550 would be $2.20. I have to write a program asking the user to enter the shipping miles and the weight and then displays the shipping charges.
I am using the JOptionPane method and this is what I have so far, but the distance is wrecking me, I can't calculate how to get the charge for the distance.
import javax.swing.JOptionPane;
public class shippingcharges
{
public static void main (String [] args)
{
double pounds,ship,m_1,m_2,m_3,m_4,distance;
String input;
input=JOptionPane.showInputDialog("Enter shpping distance");
ship=Double.parseDouble(input);
distance=ship%500;
input=JOptionPane.showInputDialog("Enter the weight");
pounds=Double.parseDouble(input);
if (pounds <=2)
JOptionPane.showMessageDialog(null,"Your shipping cost is "+m_1);
else
if (pounds >2)
JOptionPane.showMessageDialog(null,"Your shipping cost is ");
}
}
any suggestions???
Thank you:confused: