Adding a Restock Fee

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • nexcompac
    New Member
    • May 2007
    • 22

    Adding a Restock Fee

    I am getting I believe three erros in this code. I had it running perfect untill I added all the restock fee items.

    This is what I have so far:

    Code:
    import java.util.*; // program uses class Scanner
    
    public class Inventory 
    {    
        // main method begins execution of Java application
       public static void main( String args[]) 
       {    
          product[] myProduct = new product[5];      
    
            product p1 = new product("Tom Clancy Vegas", 20003, 5, 30);
            product p2 = new product("Froger", 74512, 2, 10);
            product p3 = new product("Halo 2", 20009, 3, 45);
            product p4 = new product("Night Caster", 74522, 8, 5);
            product p5 = new product("Halo 3", 32976, 1, 50);
            
            myProduct[0] = p1;
            myProduct[1] = p2;
            myProduct[2] = p3;
            myProduct[3] = p4;
            myProduct[4] = p5;
            
            double totalValue = 0.0;
            
            for (int c=0; c < 5; c++)
            {
                totalValue = totalValue + myProduct[c].itemCalculate();
            }
            
            Arrays.sort(myProduct); // function used to sort arrays
            
            for(product p: myProduct)
            {
                System.out.println(p);
                System.out.println();
            }
           System.out.println("Total Inventory value is: $"+totalValue);
       
       } //end main
        
    } //end Inventory
    The above works fine, the errors appear here below (I think because I only changed the below and got errors.


    Code:
    import java.util.*; // program uses any class available
    
    class product implements Comparable 
    {
       private String productName; // class variable that stores the item name
       private int itemNumber; // class variable that stores the item number
       private double unitProduct; // class variable that stores the quantity in 
    
    stock
       private double priceProduct; // class variable that stores the item price
       
        /** Creates a new instance of product */
        public product() // Constructor for Product class
         {
            productName = "";
            itemNumber = 0;
            unitProduct = 0.0;
            priceProduct = 0.0;
         }
        public product( String productName, int itemNumber, double unitProduct, 
    
    double priceProduct) // Constructor for myProduct class
        {
            this.productName = productName;
            this.itemNumber = itemNumber;
            this.unitProduct = unitProduct;
            this.priceProduct = priceProduct;
        }
        
          public void setProductName(String name)  // Method to set the item 
    
    name
           {
             this.productName = productName;
           }
          public String getProductName()  // Method to get the item name
           {
             return productName;
           }
          public void setItemNumber(int number)  // Method to set the item 
    
    number
           {
             this.itemNumber = itemNumber;
           }
          public int getItemNumber()  // Method to get the item name
           {
             return itemNumber;
           }
           public void setUnitProduct(double unit)  // Method to set the item 
    
    number
           {
             this.unitProduct = unitProduct;
           }
          public double getUnitProduct()  // Method to get the item name
           {
             return unitProduct;
           }
           public void setPriceProduct(double price)  // Method to set the item 
    
    number
           {
             this.priceProduct = priceProduct;
           }
          public double getPriceProduct()  // Method to get the item name
           {
             return priceProduct;
           }
          
    // Calculation method
      public double itemCalculate()
       {     
            return unitProduct * priceProduct * 2; // multiply for total for 
    
    each item
            
       } // end calculation
      public int compareTo (Object o) // use the compareTo method
        {
          product p = (product)o;
             return productName.compareTo(p.getProductName());
        }
      
      public String toString() // displays products
      {
          return "Title: "+productName+
                  "\nBarcode: "+itemNumber+
                  "\nNumber of Xbox games: "+(int)unitProduct+
                  "\nPrice: $"+priceProduct+
                  "\nTotal: $"+itemCalculate();
       } // end toString
    
       
    }//end class Supplies
    Last edited by nexcompac; Jul 30 '07, 04:27 AM. Reason: Spelling errors
  • blazedaces
    Contributor
    • May 2007
    • 284

    #2
    Care to show us the entire error and printed stack trace (shows where the error occurs)?

    -blazed

    Comment

    • nexcompac
      New Member
      • May 2007
      • 22

      #3
      Originally posted by blazedaces
      Care to show us the entire error and printed stack trace (shows where the error occurs)?

      -blazed
      I have been compiling within the bin folders at the cmd prompt.

      Product.java:61 cannot find symbol
      symbol : method value<>
      location: class product
      return value<> * 0.05;

      Product.java:65 cannot find symbol
      symbol : method value<>
      location: class product
      return value<> * 0.05;

      Product.java:82 cannot find symbol
      symbol : method value<>
      location: class product
      return value<> * 0.05;

      3 errors

      Comment

      • madhoriya22
        Contributor
        • Jul 2007
        • 251

        #4
        Originally posted by nexcompac
        I have been compiling within the bin folders at the cmd prompt.

        Product.java:61 cannot find symbol
        symbol : method value<>
        location: class product
        return value<> * 0.05;

        Product.java:65 cannot find symbol
        symbol : method value<>
        location: class product
        return value<> * 0.05;

        Product.java:82 cannot find symbol
        symbol : method value<>
        location: class product
        return value<> * 0.05;

        3 errors
        Hi,
        I think you have posted errors of different code..........e rrors doesnt belong to the code u have posted. check it again..
        Thanks and regards,
        madhoriya

        Comment

        • nexcompac
          New Member
          • May 2007
          • 22

          #5
          Yep your right.... That's what happens when your tired.

          here it is:
          Code:
          import java.util.*; // program uses any class available
          
          class product implements Comparable 
          {
             private String productName; // class variable that stores the item name
             private int itemNumber; // class variable that stores the item number
             private double unitProduct; // class variable that stores the quantity in stock
             private double priceProduct; // class variable that stores the item price
             
              /** Creates a new instance of product */
              public product() // Constructor for Product class
               {
                  productName = "";
                  itemNumber = 0;
                  unitProduct = 0.0;
                  priceProduct = 0.0;
               }
              public product( String productName, int itemNumber, double unitProduct, double priceProduct) // Constructor for myProduct class
              {
                  this.productName = productName;
                  this.itemNumber = itemNumber;
                  this.unitProduct = unitProduct;
                  this.priceProduct = priceProduct;
              }
              
                public void setProductName(String name)  // Method to set the item name
                 {
                   this.productName = productName;
                 }
                public String getProductName()  // Method to get the item name
                 {
                   return productName;
                 }
                public void setItemNumber(int number)  // Method to set the item number
                 {
                   this.itemNumber = itemNumber;
                 }
                public int getItemNumber()  // Method to get the item name
                 {
                   return itemNumber;
                 }
                 public void setUnitProduct(double unit)  // Method to set the item number
                 {
                   this.unitProduct = unitProduct;
                 }
                public double getUnitProduct()  // Method to get the item name
                 {
                   return unitProduct;
                 }
                 public void setPriceProduct(double price)  // Method to set the item number
                 {
                   this.priceProduct = priceProduct;
                 }
                public double getPriceProduct()  // Method to get the item name
                 {
                   return priceProduct;
                 }
                public double setRestockFee()  // Method to set the Restocking fee
                 {
                  return value() * 0.05;
                 }
                public double getRestockFee()  // Method to set the Restocking fee
                 {
                  return value() * 0.05;
                 }
          
          
          // Calculation method
            public double itemCalculate()
             {     
                  return unitProduct * priceProduct; // multiply for total for each item
                  
             } // end calculation
            public int compareTo (Object o) // use the compareTo method
              {
                product p = (product)o;
                   return productName.compareTo(p.getProductName());
             }
            public double RestockFee()  // Method to set the Restocking fee
               {
                  return value() * 0.05;
             }  // end
            
            public String toString() // displays products
            {
                return "Title: "+productName+
                        "\nBarcode: "+itemNumber+
                        "\nNumber of Xbox games: "+(int)unitProduct+
                        "\nPrice: $"+priceProduct+
                        "\nTotal: $"+itemCalculate();
             } // end toString
          
             
          }//end class Supplies

          Comment

          • madhoriya22
            Contributor
            • Jul 2007
            • 251

            #6
            class product implements Comparable
            {
            private String productName; // class variable that stores the item name
            private int itemNumber; // class variable that stores the item number
            private double unitProduct; // class variable that stores the quantity in stock
            private double priceProduct; // class variable that stores the item price

            /** Creates a new instance of product */
            public product() // Constructor for Product class
            {
            productName = "";
            itemNumber = 0;
            unitProduct = 0.0;
            priceProduct = 0.0;
            }
            public product( String productName, int itemNumber, double unitProduct, double priceProduct) // Constructor for myProduct class
            {
            this.productNam e = productName;
            this.itemNumber = itemNumber;
            this.unitProduc t = unitProduct;
            this.priceProdu ct = priceProduct;
            }

            public void setProductName( String name) // Method to set the item name
            {
            this.productNam e = productName;
            }
            public String getProductName( ) // Method to get the item name
            {
            return productName;
            }
            public void setItemNumber(i nt number) // Method to set the item number
            {
            this.itemNumber = itemNumber;
            }
            public int getItemNumber() // Method to get the item name
            {
            return itemNumber;
            }
            public void setUnitProduct( double unit) // Method to set the item number
            {
            this.unitProduc t = unitProduct;
            }
            public double getUnitProduct( ) // Method to get the item name
            {
            return unitProduct;
            }
            public void setPriceProduct (double price) // Method to set the item number
            {
            this.priceProdu ct = priceProduct;
            }
            public double getPriceProduct () // Method to get the item name
            {
            return priceProduct;
            }
            public double setRestockFee() // Method to set the Restocking fee
            {
            return value() * 0.05;
            }
            public double getRestockFee() // Method to set the Restocking fee
            {
            return value() * 0.05;
            }


            // Calculation method
            public double itemCalculate()
            {
            return unitProduct * priceProduct; // multiply for total for each item

            } // end calculation
            public int compareTo (Object o) // use the compareTo method
            {
            product p = (product)o;
            return productName.com pareTo(p.getPro ductName());
            }
            public double RestockFee() // Method to set the Restocking fee
            {
            return value() * 0.05;
            } // end

            }//end class Supplies
            [/CODE][/QUOTE]

            Hi,
            So here u posted the right code......see ur errors......com piler is not able to find value() method......... . coz there is no value() method in ur product(name it --Product *always start a class name with block letter only*) class...... so check it again

            thanks and regards,
            madhoriya
            Last edited by madhoriya22; Jul 30 '07, 06:24 AM. Reason: due to size

            Comment

            • nexcompac
              New Member
              • May 2007
              • 22

              #7
              I am not sure that was the issue. If I take out these lines:

              ***************
              public double RestockFee() // Method to set the Restocking fee
              {
              return value() * 0.05;
              } // end
              ***************
              public double setRestockFee() // Method to set the Restocking fee
              {
              return value() * 0.05;
              }
              public double getRestockFee() // Method to set the Restocking fee
              {
              return value() * 0.05;
              }


              Code will run fine.

              Comment

              • r035198x
                MVP
                • Sep 2006
                • 13225

                #8
                Originally posted by nexcompac
                I am not sure that was the issue. If I take out these lines:

                ***************
                public double RestockFee() // Method to set the Restocking fee
                {
                return value() * 0.05;
                } // end
                ***************
                public double setRestockFee() // Method to set the Restocking fee
                {
                return value() * 0.05;
                }
                public double getRestockFee() // Method to set the Restocking fee
                {
                return value() * 0.05;
                }


                Code will run fine.
                Where is the definition for the method value() ?

                Comment

                • madhoriya22
                  Contributor
                  • Jul 2007
                  • 251

                  #9
                  Originally posted by nexcompac
                  I am not sure that was the issue. If I take out these lines:

                  ***************
                  public double RestockFee() // Method to set the Restocking fee
                  {
                  return value() * 0.05;
                  } // end
                  ***************
                  public double setRestockFee() // Method to set the Restocking fee
                  {
                  return value() * 0.05;
                  }
                  public double getRestockFee() // Method to set the Restocking fee
                  {
                  return value() * 0.05;
                  }


                  Code will run fine.
                  Hi,
                  luk at ur getRestockFee() method again........ here u r calling value method in ur return statement..... but there is no value method in ur class.....thats why compiler is not able to resolve it... it is not wise to remove the lines where u r getting errors...... instead u should think what u need to resolve this error.... I think r035198x has given u the answer.....defi ne value() method in ur class

                  thanks and regards,
                  madhoriya

                  Comment

                  • JosAH
                    Recognized Expert MVP
                    • Mar 2007
                    • 11453

                    #10
                    I find those previous error diagnostics very suspicious:

                    Code:
                    Product.java:61 cannot find symbol
                    symbol : method value<>
                    location: class product
                    return value<> * 0.05;
                    Look at those angular brackets while the code itself seems to use ordinary
                    parentheses. Something's rotten in the state of Denmark here.

                    kind regards,

                    Jos

                    Comment

                    • r035198x
                      MVP
                      • Sep 2006
                      • 13225

                      #11
                      Originally posted by JosAH
                      I find those previous error diagnostics very suspicious:

                      Code:
                      Product.java:61 cannot find symbol
                      symbol : method value<>
                      location: class product
                      return value<> * 0.05;
                      Look at those angular brackets while the code itself seems to use ordinary
                      parentheses. Something's rotten in the state of Denmark here.

                      kind regards,

                      Jos
                      Looks suspicious indeed.
                      I ignored it thinking that maybe the OP is using a funny text editor that uses different characters for normal code pages and error output windows.

                      Comment

                      • madhoriya22
                        Contributor
                        • Jul 2007
                        • 251

                        #12
                        Originally posted by r035198x
                        Looks suspicious indeed.
                        I ignored it thinking that maybe the OP is using a funny text editor that uses different characters for normal code pages and error output windows.
                        Hi,
                        I thought he has written the errors himself instead of just copy pasting it......that why he has done the typing mistake..... not so sure ? bcoz my compiler is showing it right..
                        Code:
                        product.java:60: Method value() not found in class product.
                                return value() * 0.05;
                                            ^
                        Thanks and regards,
                        madhoriya

                        Comment

                        • nexcompac
                          New Member
                          • May 2007
                          • 22

                          #13
                          Originally posted by madhoriya22
                          Hi,
                          I thought he has written the errors himself instead of just copy pasting it......that why he has done the typing mistake..... not so sure ? bcoz my compiler is showing it right..
                          Code:
                          product.java:60: Method value() not found in class product.
                                  return value() * 0.05;
                                              ^
                          Thanks and regards,
                          madhoriya
                          In reguards to the fishy smell, cant help you with that. Try lysol. About the error. I have been trying to compile from the bin folder using the comand prompt. Since I am unaware how to copy and paste from the CMD, I just typed it out.

                          I am very new to this and my work computer will not let me install the jdk on it without admin access. I could install it if I REALLY needed to, but it is not worth getting in trouble over. =)

                          Comment

                          • r035198x
                            MVP
                            • Sep 2006
                            • 13225

                            #14
                            Originally posted by nexcompac
                            In reguards to the fishy smell, cant help you with that. Try lysol. About the error. I have been trying to compile from the bin folder using the comand prompt. Since I am unaware how to copy and paste from the CMD, I just typed it out.

                            I am very new to this and my work computer will not let me install the jdk on it without admin access. I could install it if I REALLY needed to, but it is not worth getting in trouble over. =)
                            Eh, do you mean to say that you compiled that code without the JDK?

                            Try using Textpad. You can compile and run certain programs from it.

                            P.S Are the errors gone now?

                            Comment

                            • JosAH
                              Recognized Expert MVP
                              • Mar 2007
                              • 11453

                              #15
                              Originally posted by nexcompac
                              In reguards to the fishy smell, cant help you with that. Try lysol.
                              Lol!

                              kind regards,

                              Jos :-)

                              Comment

                              Working...