Results 1 to 3 of 3
  1. #1
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Default Inventory Program Part 2 of 6

    O.k to begin with Inventory Program Part 1 we were to chose a product that lends itself to an inventory ( for example, products at your workplace, office supplies, music CDs, DVD movies, or software) Create a product class that holds the itme number, the name of the product, the number of units in stock, and the price of each unit. Create a Java application that displays the product number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory (the number of units in stock multiplied by the price of each unit). Pay attention to the good programming practices in the text to ensure your source code is readable and well documented. Post as attachment in java format.


    I know no one has the same reading material as me so just skip that part. By accident I think I turned in to the teacher Part 2 instead of part one.

    And part 2 Modify the Inventory Program so the application can handle multiple items. Use an array to store the items. The output should display the information one product at a time, including the item number, the name of the product, the number of units in stock, the price of each unit, and the value of the inventory of that product. In addition, the output should display the value of the entire inventory.
    Create a method to calculate the value of the entire inventory.
    Create another method to sort the array items by the name of the product.

    I will post the code which does work. I would like for someone who knows Java to be able to tell me whether this application applies to both parts one and two or just one or two. If this is at all possible. OK here goes:
    // Inventory Program
    Java Code:
    import javax.swing.JOptionPane;
    import java.text.*;
    import static java.lang.Math.*;
    
    public class cdinventory
    {
        
    public static class cd
    {
        String itemnumber;
        String itemname;
        int numberinstock;
        double unitprice;
        double inventoryvalue;
        public cd (String cdnum, String cdname, int numinstock, double cdprice, double totalvalue)
        {
            itemnumber=cdnum;
            itemname=cdname;
            numberinstock=numinstock;
            unitprice=cdprice;
            inventoryvalue=totalvalue;
          }//end constructor public cd
          
          public static class cdartist
          {
              String artistname;
              int itemsWithArtistName;
              double unitprice;
              public double artistinventory;
              {
                   
              }
              
          }
    }//end subclass cd
    public static void main(String[] args)
    {
        cd[] cdcollection = new cd [150];
    
        // prompt user to enter cdname
        
        String cdname =                                          
             JOptionPane.showInputDialog("Enter CD name or quit to quit: ");
          
        // create the message
        String message =                                              
             String.format("The CD name is: ", cdname);
             
    
        // display the message to welcome the user by name 
        JOptionPane.showMessageDialog( null, message );    
    }//end method main
    }//end class cdinventory

  2. #2
    Mr.Beans's Avatar
    Mr.Beans is offline Senior Member
    Join Date
    Apr 2009
    Location
    Virginia Beach, Virginia
    Posts
    149
    Rep Power
    0

    Default

    What do you think the code does?

    The code doesn't complete the description given above. Where does it sort the items?

    To sort the items by name you should take a look at how the String class implements the Comparable interface.

    Mr.Beans

  3. #3
    tlouvierre is offline Member
    Join Date
    Apr 2009
    Location
    I live Stafford Texas right outside of Houston.
    Posts
    78
    Rep Power
    0

    Default

    Ok so what you are saying is that the program only functions for part 1 and not part 2. Is that correct? Because I can always work with that. Thankyou for your help!

Similar Threads

  1. Inventory Program Part 3 ~ please help!
    By marMcD in forum New To Java
    Replies: 13
    Last Post: 02-25-2009, 05:57 AM
  2. Java Inventory Program Part 3
    By ljk8950 in forum New To Java
    Replies: 18
    Last Post: 07-28-2008, 05:47 AM
  3. Inventory Program Part 3 - DUE TODAY (7/28/08)
    By ljk8950 in forum New To Java
    Replies: 7
    Last Post: 07-27-2008, 10:28 PM
  4. Inventory part 3 program problems
    By badness in forum New To Java
    Replies: 1
    Last Post: 12-17-2007, 07:00 AM
  5. Inventory part 2 help please
    By badness in forum New To Java
    Replies: 1
    Last Post: 12-12-2007, 07:51 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •