mickie mae erpelo
2014-08-09 13:22:34 UTC
These are my codes. the error is Package.java:143: error: <identifier>
Help me please? What should i do?
import javax.swing.*;
public class Package
{
private int packageWeight;
private char shippingMethod;
private double shippingCost;
public final double AIRSMALLPACKAGE = 2.00;
public final double AIRMEDIUMPACKAGE = 3.00;
public final double AIRHEAVYPACKAGE = 4.50;
public final double TRUCKLIGHTPACKAGE = 1.50;
public final double TRUCKMEDIUMPACKAGE = 2.50;
public final double TRUCKHEAVYPACKAGE = 3.25;
public final double MAILLIGHTPACKAGE = 0.50;
public final double MAILMEDIUMPACKAGE = 1.50;
public final double MAILHEAVYPACKAGE = 2.15;
//DEFAULT CONSTRUCTOR
public Package(int pacWeight, char shipMethod)
{
packageWeight = pacWeight;
shippingMethod = shipMethod;
shippingCost = calculateCost();
}
//METHOD TO GET AND SET PACKAGE WEIGHT
public int getWeight()
{
return packageWeight;
}
public void setWeight()
{
String weightOfPackage = new String(" ");
weightOfPackage = JOptionPane.showInputDialog(null, "Please enter the package weight?");
packageWeight = Integer.parseInt(weightOfPackage);
}
//METHOD TO GET AND SET PACKAGE SHIPPING COST
public char getShipMethod()
{
return shippingMethod;
}
public void setShipMethod(char shippingMethod)
{
String s = (JOptionPane.showInputDialog(null, "How would you like the package shipped, (A)ir, (T)ruck, or (M)ail ?"));
shippingMethod = s.charAt(0);
}
//METHOD TO GET AND SET PACKAGE SHIPPING COST
public double getCost()
{
return shippingCost;
}
public void setCost(double sCost)
{
shippingCost = sCost;
}
//METHOD TO CALCULATE SHIPPING COSTS
private double calculateCost()
{
double shipCost = 0;
if (packageWeight >= 1 && packageWeight <= 8)
{
if (shippingMethod == 'A') //Air Shipping
{
shipCost = AIRSMALLPACKAGE * packageWeight;
}
else if (shippingMethod == 'T') //Truck Shipping
{
shipCost = TRUCKLIGHTPACKAGE * packageWeight;
}
else if (shippingMethod == 'M') //Mail Shipping
{
shipCost = MAILLIGHTPACKAGE * packageWeight;
}
}
else if (packageWeight >=9 && packageWeight <= 16)
{
if (shippingMethod == 'A') //Air Shipping
{
shipCost = AIRMEDIUMPACKAGE * packageWeight;
}
else if (shippingMethod == 'T') //Truck Shipping
{
shipCost = TRUCKMEDIUMPACKAGE * packageWeight;
}
else if (shippingMethod == 'M') //Mail Shipping
{
shipCost = MAILMEDIUMPACKAGE * packageWeight;
}
}
else if (packageWeight >= 17)
{
if (shippingMethod == 'A') //Air Shipping
{
shipCost = AIRHEAVYPACKAGE * packageWeight;
}
else if (shippingMethod == 'T') //Truck Shipping
{
shipCost = TRUCKHEAVYPACKAGE * packageWeight;
}
else if (shippingMethod == 'M') //Mail Shipping
{
shipCost = MAILHEAVYPACKAGE * packageWeight;
}
}
return shipCost;
}
//METHOD TO DISPLAY RESULTS
public String display()
{
return "Package Weight: " + packageWeight + "ounce(s), Shipping Method: " + displayMethod() + ", Shipping Cost: $" + shippingCost;
}
//METHOD TO ASSIGN AND DISPLAY PACKAGE WEIGHT
public String displayMethod()
{
String method = "";
if (shippingMethod=='A')
{
method = "Air";
}
else if (shippingMethod=='T')
{
method = "Truck";
}
else if (shippingMethod=='M')
{
method = "Mail";
}
return method;
try
{
int word;
JOptionPane.showMessageDialog( null, "Please enter a word" );
word = Interger.parseInt(word);
}
catch(NumberFormatException)
{
JOptionPane.showMessageDialog( null, "Error");
}
}
}
Help me please? What should i do?
import javax.swing.*;
public class Package
{
private int packageWeight;
private char shippingMethod;
private double shippingCost;
public final double AIRSMALLPACKAGE = 2.00;
public final double AIRMEDIUMPACKAGE = 3.00;
public final double AIRHEAVYPACKAGE = 4.50;
public final double TRUCKLIGHTPACKAGE = 1.50;
public final double TRUCKMEDIUMPACKAGE = 2.50;
public final double TRUCKHEAVYPACKAGE = 3.25;
public final double MAILLIGHTPACKAGE = 0.50;
public final double MAILMEDIUMPACKAGE = 1.50;
public final double MAILHEAVYPACKAGE = 2.15;
//DEFAULT CONSTRUCTOR
public Package(int pacWeight, char shipMethod)
{
packageWeight = pacWeight;
shippingMethod = shipMethod;
shippingCost = calculateCost();
}
//METHOD TO GET AND SET PACKAGE WEIGHT
public int getWeight()
{
return packageWeight;
}
public void setWeight()
{
String weightOfPackage = new String(" ");
weightOfPackage = JOptionPane.showInputDialog(null, "Please enter the package weight?");
packageWeight = Integer.parseInt(weightOfPackage);
}
//METHOD TO GET AND SET PACKAGE SHIPPING COST
public char getShipMethod()
{
return shippingMethod;
}
public void setShipMethod(char shippingMethod)
{
String s = (JOptionPane.showInputDialog(null, "How would you like the package shipped, (A)ir, (T)ruck, or (M)ail ?"));
shippingMethod = s.charAt(0);
}
//METHOD TO GET AND SET PACKAGE SHIPPING COST
public double getCost()
{
return shippingCost;
}
public void setCost(double sCost)
{
shippingCost = sCost;
}
//METHOD TO CALCULATE SHIPPING COSTS
private double calculateCost()
{
double shipCost = 0;
if (packageWeight >= 1 && packageWeight <= 8)
{
if (shippingMethod == 'A') //Air Shipping
{
shipCost = AIRSMALLPACKAGE * packageWeight;
}
else if (shippingMethod == 'T') //Truck Shipping
{
shipCost = TRUCKLIGHTPACKAGE * packageWeight;
}
else if (shippingMethod == 'M') //Mail Shipping
{
shipCost = MAILLIGHTPACKAGE * packageWeight;
}
}
else if (packageWeight >=9 && packageWeight <= 16)
{
if (shippingMethod == 'A') //Air Shipping
{
shipCost = AIRMEDIUMPACKAGE * packageWeight;
}
else if (shippingMethod == 'T') //Truck Shipping
{
shipCost = TRUCKMEDIUMPACKAGE * packageWeight;
}
else if (shippingMethod == 'M') //Mail Shipping
{
shipCost = MAILMEDIUMPACKAGE * packageWeight;
}
}
else if (packageWeight >= 17)
{
if (shippingMethod == 'A') //Air Shipping
{
shipCost = AIRHEAVYPACKAGE * packageWeight;
}
else if (shippingMethod == 'T') //Truck Shipping
{
shipCost = TRUCKHEAVYPACKAGE * packageWeight;
}
else if (shippingMethod == 'M') //Mail Shipping
{
shipCost = MAILHEAVYPACKAGE * packageWeight;
}
}
return shipCost;
}
//METHOD TO DISPLAY RESULTS
public String display()
{
return "Package Weight: " + packageWeight + "ounce(s), Shipping Method: " + displayMethod() + ", Shipping Cost: $" + shippingCost;
}
//METHOD TO ASSIGN AND DISPLAY PACKAGE WEIGHT
public String displayMethod()
{
String method = "";
if (shippingMethod=='A')
{
method = "Air";
}
else if (shippingMethod=='T')
{
method = "Truck";
}
else if (shippingMethod=='M')
{
method = "Mail";
}
return method;
try
{
int word;
JOptionPane.showMessageDialog( null, "Please enter a word" );
word = Interger.parseInt(word);
}
catch(NumberFormatException)
{
JOptionPane.showMessageDialog( null, "Error");
}
}
}