Homework Help for Java

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • DonE
    New Member
    • Mar 2008
    • 1

    Homework Help for Java

    Help me please. I am having problems with my homework assignment. We are to create a product class that hold the item number, the name of the product, the number of units in stock, and the price of each unit. Here is my problem. I have written the program ( I use netbean) and I have encountered plenty of errors. The error messages that I get are as follows:
    1. illegal start type
    2. cannot find symbol
    3. operator cannot be applied
    4. assignment to itself


    Here is what I have done so far. It would be great if there would be someone that would be able to help me throughout the next few weeks of assignments. Thanks
    DonE


    public class DVDInventory
    {
    //Inventory for DVD


    import java.util.*;
    import javax.swing.*;
    import java.awt.event. *;
    import java.awt.*;

    class product comparable
    {
    String name; //class variable that stores item name
    double number; //class variable that stores item number
    long stockQuantity; //class variable that stores the quantity in stock
    double price; //class variable that stores the items price
    public product();
    {
    name = "";
    number = 0.0;
    stockQuantity = OL;
    price = 0.0;
    }
    public product(String name,int number,long stockQuantity,d ouble price);
    {
    this.name = name
    this.number = number;
    this.stockQuant ity = stockQuantity;
    this.price = price;

    }
    public void setItemName(Str ing name)
    {
    this.name = name;
    }
    public String getItemName()
    {
    return name;
    }
    public void setItemNumber(d ouble number)
    {
    this.number = number;
    }
    public double getItemNumber()
    {
    return number;
    }
    public void setstockQuantit y(long quantity)
    {
    stockQuantity = quantity;
    }
    public long getstockQuantit y()
    {
    stockQuantity = quantity;
    }
    public long get stockQuantity()
    {
    return stockQuantity;
    }
    public void setItemPrice(do uble price)
    {
    this.price = price;
    }
    public double getItemPrice()
    {
    return price;
    }
    public double calculateInvent oryValue()
    {
    return getItemPrice()* getStockQuantit y();
    }

    public StringtoString( )
    {
    return "\nName:"+getIt emName()+"\nNum ber:"+number"\n price:$"+price+
    "\nQuantity:"+s tockQuantity+"\ nValue:$"+calcu latInventoryVal ue();
    }//end product
    class DVD(String name, int number, long stockQuantity, double price,
    String titles)

    private String titles;
    public DVD()
    {
    super();//call constructor in product
    titles = "";//add the additional attribute
    }

    Public DVD(String name, int number, long stockQuantity, double price,
    String titles)
    {
    super(name, number, stockQuality, price); //call constructor in product
    this.titles = titles; //add the additional attribute
    }
    public void settitle(String title)
    {
    this.titles = titles;
    }
    public string gettitles()
    {
    return titles;
    }
    public double calculateInvent oryValue()
    {
    return getItenPrice()* getstockQuantit y();
    }
    return "\nName:"+getIt emName()+"\nNum ber:"+getItemNu mber()+"\nPrice :$"
    +getItemPrice() +"\nQuantity:"+ getstockQuantit y()+"\ntitles:"
    gettitles()+"\n Value:$"+Calcul ateInventoryVal ue();
    }}

    }//end DVD
  • JosAH
    Recognized Expert MVP
    • Mar 2007
    • 11453

    #2
    Originally posted by DonE
    1. illegal start type
    2. cannot find symbol
    3. operator cannot be applied
    4. assignment to itself
    The compiler tells you a lot more than just that, e.g. it shows the line number
    where the compilation error was noticed, it displays the offending symbol(s)
    and more when it can. Please don't let us guess about that information.

    kind regards,

    Jos

    Comment

    • sukatoa
      Contributor
      • Nov 2007
      • 539

      #3
      Originally posted by DonE
      Help me please. I am having problems with my homework assignment. We are to create a product class that hold the item number, the name of the product, the number of units in stock, and the price of each unit. Here is my problem. I have written the program ( I use netbean) and I have encountered plenty of errors. The error messages that I get are as follows:
      1. illegal start type
      2. cannot find symbol
      3. operator cannot be applied
      4. assignment to itself


      Here is what I have done so far. It would be great if there would be someone that would be able to help me throughout the next few weeks of assignments. Thanks
      DonE


      public class DVDInventory
      {
      //Inventory for DVD


      import java.util.*;
      import javax.swing.*;
      import java.awt.event. *;
      import java.awt.*;

      class product comparable
      {
      String name; //class variable that stores item name
      double number; //class variable that stores item number
      long stockQuantity; //class variable that stores the quantity in stock
      double price; //class variable that stores the items price
      public product();
      {
      name = "";
      number = 0.0;
      stockQuantity = OL;
      price = 0.0;
      }
      public product(String name,int number,long stockQuantity,d ouble price);
      {
      this.name = name
      this.number = number;
      this.stockQuant ity = stockQuantity;
      this.price = price;

      }
      public void setItemName(Str ing name)
      {
      this.name = name;
      }
      public String getItemName()
      {
      return name;
      }
      public void setItemNumber(d ouble number)
      {
      this.number = number;
      }
      public double getItemNumber()
      {
      return number;
      }
      public void setstockQuantit y(long quantity)
      {
      stockQuantity = quantity;
      }
      public long getstockQuantit y()
      {
      stockQuantity = quantity;
      }
      public long get stockQuantity()
      {
      return stockQuantity;
      }
      public void setItemPrice(do uble price)
      {
      this.price = price;
      }
      public double getItemPrice()
      {
      return price;
      }
      public double calculateInvent oryValue()
      {
      return getItemPrice()* getStockQuantit y();
      }

      public StringtoString( )
      {
      return "\nName:"+getIt emName()+"\nNum ber:"+number"\n price:$"+price+
      "\nQuantity:"+s tockQuantity+"\ nValue:$"+calcu latInventoryVal ue();
      }//end product
      class DVD(String name, int number, long stockQuantity, double price,
      String titles)

      private String titles;
      public DVD()
      {
      super();//call constructor in product
      titles = "";//add the additional attribute
      }

      Public DVD(String name, int number, long stockQuantity, double price,
      String titles)
      {
      super(name, number, stockQuality, price); //call constructor in product
      this.titles = titles; //add the additional attribute
      }
      public void settitle(String title)
      {
      this.titles = titles;
      }
      public string gettitles()
      {
      return titles;
      }
      public double calculateInvent oryValue()
      {
      return getItenPrice()* getstockQuantit y();
      }
      return "\nName:"+getIt emName()+"\nNum ber:"+getItemNu mber()+"\nPrice :$"
      +getItemPrice() +"\nQuantity:"+ getstockQuantit y()+"\ntitles:"
      gettitles()+"\n Value:$"+Calcul ateInventoryVal ue();
      }}

      }//end DVD
      Just a reminder that next time, use code tags when you are to post java codes... ;-)

      Sukatoa.

      Comment

      Working...