Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.java.help > #2987

Help please

Newsgroups comp.lang.java.help
Date 2014-08-09 06:22 -0700
Message-ID <071eb276-0134-472a-9815-0505403554a6@googlegroups.com> (permalink)
Subject Help please
From mickie mae erpelo <ememerpz@gmail.com>

Show all headers | View raw


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");
   }
  
   }  
   
}

Back to comp.lang.java.help | Previous | NextNext in thread | Find similar | Unroll thread


Thread

Help please mickie mae erpelo <ememerpz@gmail.com> - 2014-08-09 06:22 -0700
  Re: Help please Eric Sosman <esosman@comcast-dot-net.invalid> - 2014-08-09 09:30 -0400
  Re: Help please Jeff Higgins <jeff@invalid.invalid> - 2014-08-09 11:56 -0400

csiph-web