473,386 Members | 1,819 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

Where do I go from here with my Inventory Program?

I am so lost when it comes to Java. I have the first part of an Inventory Program and I need to modify it so that it contains a second class and a sort and calculate method. I also have to use an array for the inventory class. I have one more day to get this, can you please help? [Edit]Code removed in accordance with the posting guidelines[/Edit]
May 7 '07 #1
4 1798
r035198x
13,262 8TB
I am so lost when it comes to Java. I have the first part of an Inventory Program and I need to modify it so that it contains a second class and a sort and calculate method. I also have to use an array for the inventory class. I have one more day to get this, can you please help?
Expand|Select|Wrap|Line Numbers
  1. // Inventory.java
  2. // Program that displays the value of a product in inventory.
  3.  
  4. import java.util.Scanner; // program uses class Scanner
  5.  
  6. class Product
  7.  
  8. {
  9. private double itemnum; // class variable that stores Item number
  10. private double prodprice; // class variable that stores tprice of the product
  11. private double numinstock; // class variable that stores the number of product in stock
  12. private String prodname; //class variable for the name of the product
  13.  
  14. public Product() // Constructor for the Item
  15. {
  16. itemnum = 0.0;
  17. prodprice = 0.0;
  18. numinstock = 0.0;
  19. }
  20. public void setItemnum(double num) // Method to set the Item number
  21. {
  22. itemnum = num;
  23. }
  24. public double getItemnum() // Method to get the Item number
  25. {
  26. return itemnum;
  27. }
  28. public void setProdprice(double prod) // Method to set the Price of the product
  29. {
  30. prodprice = prod;
  31. }
  32. public double getProdprice() // Method to get the Price of the product
  33. {
  34. return prodprice;
  35. }
  36. public void setNuminstock(double numstock) // Method to set the Price of the product
  37. {
  38. numinstock = numstock;
  39. }
  40. public double getNuminstock() // Method to get the Price of the product
  41. {
  42. return numinstock;
  43. }
  44. public void setProdname(String name) // Method to set the name of the product
  45. {
  46. prodname = name;
  47. }
  48. public String getProdname() // Method to get the name of the product
  49. {
  50. return prodname;
  51. }
  52. public double calculateValue() // Method to calculate the weekly pay
  53. {
  54. return prodprice * numinstock;
  55. }
  56.  
  57. }//end class Product
  58.  
  59. public class Inventory
  60.  
  61. {
  62. public static void main( String args[] )
  63. {
  64. // create Scanner to obtain input
  65. Scanner input = new Scanner( System.in );
  66.  
  67. //Instantiate an Item object
  68. // item myItem = new Item();
  69. Product myItem = new Product();
  70.  
  71. //Print out a screen title
  72. System.out.printf("Inventory Program\n\n");
  73.  
  74. System.out.println( "Enter the name of product or the word stop: " ); // prompt for input
  75. myItem.setProdname(input.nextLine());// read item name or stop
  76.  
  77. // while loop to repeat the entry of the item until stop is entered
  78. while (!(myItem.getProdname().equalsIgnoreCase("stop") ) )
  79. // start while
  80. {
  81. //Enter Item number
  82. System.out.print( "Enter the Item number: " ); // prompt for input
  83. myItem.setItemnum(input.nextDouble());// read item number
  84.  
  85. // while loop to repeat the entry of the item number until a positive value is entered
  86. while (myItem.getItemnum()<=0.0)
  87. {
  88. System.out.println("Wrong Entry");
  89. System.out.println("Please enter a positive Item Number:");
  90. myItem.setItemnum(input.nextDouble()); // read Item number
  91. }
  92.  
  93. // Enter Number of Items in Stock
  94. System.out.print("Enter number of Items in Stock:");
  95. myItem.setNuminstock(input.nextDouble()); // read Number of Items in Stock
  96.  
  97. // while loop to repeat the entry of Items in stock until a positive value is entered
  98. while (myItem.getNuminstock()<=0.0)
  99. {
  100. System.out.println("Wrong Entry");
  101. System.out.println("Please enter a positive Number in Stock:");
  102. myItem.setNuminstock(input.nextDouble()); // read Item number
  103. }
  104.  
  105. // Enter price of the Item
  106. System.out.print( "Enter the price of the item: " ); // prompt for price
  107. myItem.setProdprice(input.nextDouble()); // Read price of the product
  108.  
  109. // while loop to repeat the entry of Items in stock until a positive value is entered
  110. while (myItem.getProdprice()<=0.0)
  111. {
  112. System.out.println("Wrong Entry");
  113. System.out.println("Please enter a positive value for Item Price:");
  114. myItem.setProdprice(input.nextDouble()); // read Item Price
  115. }
  116.  
  117. System.out.printf("The value %s is $ %.2f\n\n\n", myItem.
  118. // getItemname(),myItemname.calculatevalue() ); // display the calculated inventory value
  119. getProdname(),myItem.calculateValue() ); // display the calculated inventory value
  120.  
  121. System.out.println("Enter the name of the product or 'stop':"); // prompt for name
  122. // myItem.setItemname(input.next()); /// read item name or stop
  123. myItem.setProdname(input.next()); /// read item name or stop
  124.  
  125. } // end while
  126.  
  127. } // end method main
  128.  
  129. } // end class Inventory
  130.  
  131.  
  132.  
1.) You don't need to post all your code like this.
2.) Go step by step with your problem if you get stuck somewhere post for help on that specific point only and indicate your ideas on it as well.
May 7 '07 #2
1.) You don't need to post all your code like this.
2.) Go step by step with your problem if you get stuck somewhere post for help on that specific point only and indicate your ideas on it as well.
If you are trying to sort try doing something like this:


Expand|Select|Wrap|Line Numbers
  1.  public void nameSort()
  2.    {
  3.       for (int i = 1; i < stores.length; i++)
  4.       {
  5.          int j;
  6.          Product val = stores[i];
  7.          for (j = i - 1; j > -1; j--)
  8.          {
  9.             Product temp = stores[j];
  10.             if (temp.compareTo(val) <= 0)
  11.             {
  12.                break;
  13.             }
  14.             stores[j + 1] = temp;
  15.          }
  16.          stores[j + 1] = val;
  17.       }
  18.    }//end method nameSort
May 8 '07 #3
Banfa
9,065 Expert Mod 8TB
lucky29105,

please read this forums posting guidelines.

It is not permissible to post the full code on this forum either as a question or answer in relation to a homework question.

If you are having a basic problem understanding your assignment you should talk to your tutor.

If you continue to post full code in relation to a homework question you will initially receive a temporary site ban and then a permanent ban if you continue after the temporary one.
May 20 '07 #4
I apologize- I dont have much experience with programming, and it wasnt until after I had posted my message that I realized I had done it wrong.

lucky29105,

please read this forums posting guidelines.

It is not permissible to post the full code on this forum either as a question or answer in relation to a homework question.

If you are having a basic problem understanding your assignment you should talk to your tutor.

If you continue to post full code in relation to a homework question you will initially receive a temporary site ban and then a permanent ban if you continue after the temporary one.
May 25 '07 #5

Sign in to post your reply or Sign up for a free account.

Similar topics

5
by: gregork | last post by:
I have painstakingly created an excel 2000 workbook for the very complex recipes I have to formulate. I have 2 sheets- 1 for configuring the recipe and 1 that is like an inventory of all the raw...
12
by: qt1504 | last post by:
I have two small stores in two different building which is not a LAN network. However, each has an internet access. I am trying to write an inventory program which manage inventory two stores. ...
67
by: hollywoood | last post by:
I am trying to add the Delete button, save and search buttons. I have tried to call my teacher and he is absolutly no help and i have read and reread the text but still have no idea what is going...
9
by: xxplod | last post by:
I am suppose to 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...
3
by: cblank | last post by:
I need some help if someone could help me. I know everyone is asking for help in java. But for some reason I'm the same as everyone else when it comes to programming in java. I have an inventory...
5
by: cblank | last post by:
I'm having some trouble with my inventory program. Its due tom and my teacher is not wanting to help. He keeps giving me a soluction that is not related to my code. I have everything working except...
1
by: jcato77 | last post by:
I need help with a class project I'm working on, Below is my assignment and the code I have currently created. Assignment: Modify the Inventory Program by creating a subclass of the product class...
2
by: blitz1989 | last post by:
Hello all, I'm new to this forum and Java and having a alot of problems understanding this language. I am working on an invetory program part 4. The assignment requirements are listed but the...
16
by: lilsugaman | last post by:
I have to assignment which includes the following: Modify the Inventory Program so the application can handle multiple items. Use an array to store the items. The output should display the...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.