Results 1 to 3 of 3
Thread: Inventory Program Part 2 of 6
- 05-28-2009, 12:38 AM #1
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
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
- 05-28-2009, 12:56 AM #2
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
- 05-28-2009, 01:30 AM #3
Member
- Join Date
- Apr 2009
- Location
- I live Stafford Texas right outside of Houston.
- Posts
- 78
- Rep Power
- 0
Similar Threads
-
Inventory Program Part 3 ~ please help!
By marMcD in forum New To JavaReplies: 13Last Post: 02-25-2009, 05:57 AM -
Java Inventory Program Part 3
By ljk8950 in forum New To JavaReplies: 18Last Post: 07-28-2008, 05:47 AM -
Inventory Program Part 3 - DUE TODAY (7/28/08)
By ljk8950 in forum New To JavaReplies: 7Last Post: 07-27-2008, 10:28 PM -
Inventory part 3 program problems
By badness in forum New To JavaReplies: 1Last Post: 12-17-2007, 07:00 AM -
Inventory part 2 help please
By badness in forum New To JavaReplies: 1Last Post: 12-12-2007, 07:51 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks