473,396 Members | 2,154 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,396 software developers and data experts.

Program help...

Here is my Inventory program for my Java class....

Expand|Select|Wrap|Line Numbers
  1. //Inventory.java
  2. //Class created to store item information for Inventory purposes
  3. //Created November 15, 2006
  4. //Modified November 29, 2006
  5. //Audrey A. Paige
  6. //IT315
  7.  
  8. class Product
  9. {
  10.    private String name;     // class variable that stores the item name
  11.    private double number;      // class variable that stores the item number
  12.    private long stockQuantity;   // class variable that stores the quantity in stock
  13.    private double price;      // class variable that stores the item price
  14.    public Product() // Constructor for the Supplies class
  15.    {
  16.       name = "";
  17.       number = 0.0;
  18.       stockQuantity = 0L;
  19.       price = 0.0;
  20.    }
  21.    public Product(String name, int number, long stockQuantity, double price) // Constructor for the Supplies class
  22.       {
  23.          this.name = name;
  24.          this.number = number;
  25.          this.stockQuantity = stockQuantity;
  26.          this.price = price;
  27.    }
  28.    public void setItemName(String name)  // Method to set the item name
  29.    {
  30.       this.name = name;
  31.    }
  32.    public String getItemName()  // Method to get the item name
  33.    {
  34.       return name;
  35.    }
  36.    public void setItemNumber(double number)  // Method to set the item number
  37.    {
  38.       this.number = number;
  39.    }
  40.    public double getItemNumber()  // Method to get the item number
  41.    {
  42.       return number;
  43.    }
  44.    public void setStockQuantity(long quantity)  // Method to set the quantity in stock
  45.    {
  46.       stockQuantity = quantity;
  47.    }
  48.    public long getStockQuantity()  // Method to get the quantity in stock
  49.    {
  50.       return stockQuantity;
  51.    }
  52.    public void setItemPrice(double price)  // Method to set the item price
  53.    {
  54.       this.price = price;
  55.    }
  56.    public double getItemPrice()  // Method to get the item price
  57.    {
  58.       return price;
  59.    }
  60.    public double calculateInventoryValue()  // Method to calculate the value of the inventory
  61.    {
  62.       return price * stockQuantity;
  63.    }
  64. }//end class Product
  65.  
  66. public class Inventory
  67. {
  68.    // main methods begins execution of java application
  69.    public static void main( String args[])
  70.    {
  71.     Product p = new Product("Pencil", 5460, 125, 1.5);
  72.     System.out.printf("\n\nItem Name:%s\n",p.getItemName()); //display item name
  73.     System.out.printf("Item Number:%s\n",p.getItemNumber()); //display item number
  74.     System.out.printf("Quantity in Stock:%s\n",p.getStockQuantity()); //display quantity in stock
  75.     System.out.printf("Item Price:$%.2f\n",p.getItemPrice()); //display item price
  76.     System.out.printf("Value of Inventory:$%.2f\n",p.calculateInventoryValue()); //display total value of inventory for this item
  77.  
  78.  
  79.    } // end main method
  80. }//end class Inventory
I need to add these changes...

1. CheckPoint: Inventory Program Part 2
• Resource: Java: How to Program
• Due Date: Day 4 [Individual] forum
• 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.

If anyone can help it would be greatly appreciated... I am getting desperate-my class ends next week, and I still have to figure out three more modifications of this program...

Thanks!
Nov 29 '06 #1
2 3956
r035198x
13,262 8TB
Here is my Inventory program for my Java class....

Expand|Select|Wrap|Line Numbers
  1. //Inventory.java
  2. //Class created to store item information for Inventory purposes
  3. //Created November 15, 2006
  4. //Modified November 29, 2006
  5. //Audrey A. Paige
  6. //IT315
  7.  
  8. class Product
  9. {
  10. private String name;     // class variable that stores the item name
  11. private double number;     // class variable that stores the item number
  12. private long stockQuantity; // class variable that stores the quantity in stock
  13. private double price;     // class variable that stores the item price
  14. public Product() // Constructor for the Supplies class
  15. {
  16.      name = "";
  17.      number = 0.0;
  18.      stockQuantity = 0L;
  19.      price = 0.0;
  20. }
  21. public Product(String name, int number, long stockQuantity, double price) // Constructor for the Supplies class
  22.      {
  23.          this.name = name;
  24.          this.number = number;
  25.          this.stockQuantity = stockQuantity;
  26.          this.price = price;
  27. }
  28. public void setItemName(String name) // Method to set the item name
  29. {
  30.      this.name = name;
  31. }
  32. public String getItemName() // Method to get the item name
  33. {
  34.      return name;
  35. }
  36. public void setItemNumber(double number) // Method to set the item number
  37. {
  38.      this.number = number;
  39. }
  40. public double getItemNumber() // Method to get the item number
  41. {
  42.      return number;
  43. }
  44. public void setStockQuantity(long quantity) // Method to set the quantity in stock
  45. {
  46.      stockQuantity = quantity;
  47. }
  48. public long getStockQuantity() // Method to get the quantity in stock
  49. {
  50.      return stockQuantity;
  51. }
  52. public void setItemPrice(double price) // Method to set the item price
  53. {
  54.      this.price = price;
  55. }
  56. public double getItemPrice() // Method to get the item price
  57. {
  58.      return price;
  59. }
  60. public double calculateInventoryValue() // Method to calculate the value of the inventory
  61. {
  62.      return price * stockQuantity;
  63. }
  64. }//end class Product
  65.  
  66. public class Inventory
  67. {
  68. // main methods begins execution of java application
  69. public static void main( String args[])
  70. {
  71. Product p = new Product("Pencil", 5460, 125, 1.5);
  72.     System.out.printf("\n\nItem Name:%s\n",p.getItemName()); //display item name
  73.     System.out.printf("Item Number:%s\n",p.getItemNumber()); //display item number
  74.     System.out.printf("Quantity in Stock:%s\n",p.getStockQuantity()); //display quantity in stock
  75.     System.out.printf("Item Price:$%.2f\n",p.getItemPrice()); //display item price
  76.     System.out.printf("Value of Inventory:$%.2f\n",p.calculateInventoryValue()); //display total value of inventory for this item
  77.  
  78.  
  79. } // end main method
  80. }//end class Inventory
I need to add these changes...

1. CheckPoint: Inventory Program Part 2
• Resource: Java: How to Program
• Due Date: Day 4 [Individual] forum
• 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.

If anyone can help it would be greatly appreciated... I am getting desperate-my class ends next week, and I still have to figure out three more modifications of this program...

Thanks!
Keep one question in one thread please. What happened to the last stage we reached in this thread

http://www.thescripts.com/forum/thread570714.html
Nov 30 '06 #2
Sorry, I am new to the forum. My teacher liked the first one, but the second one she said the for loops were wrong, the addProduct part was unnecessary, and that I should create the array and add the items in the main method. She also said she doesn't care how I do the sort-I can use bubble or the utility.

I am just basically at the end of my rope with her. She said I will not get any credit for the first three checkpoints, so I basically have to find a way to get from one to five in the next week,

I really appreciate you help and am hoping you can help me more. My teacher is proving to be very little help at all...
Nov 30 '06 #3

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

Similar topics

11
by: anuradha.k.r | last post by:
hi, i am writing a socket program in python,both client side and server side.I've written the client side which is working perfectly fine(checked it against server program written in C).but as for...
2
by: stanlo | last post by:
Hallo to everyone, i am just begining to learn c++ even though i did pascal when i studied mathematics in the univesity.i just took on my self a project which writing a c++ program which does...
7
by: tyler_durden | last post by:
thanks a lot for all your help..I'm really appreciated... with all the help I've been getting in forums I've been able to continue my program and it's almost done, but I'm having a big problem that...
1
by: Willing 2 Learn | last post by:
Below is a program I did to recognize a Finite State Automata for ASCII (J+H)*. I got that one working but im having trouble getting the NFA program to work. I really desperately need help! My...
66
by: genestarwing | last post by:
QUESTION: Write a program that opens and read a text file and records how many times each word occurs in the file. Use a binary search tree modified to store both a word and the number of times it...
12
by: asif929 | last post by:
I am trying to write a program which creates four triangles. The program begins with prompting a user " Enter the size of triangles", number from 1 to N is the size of four triangles For Example if...
21
by: asif929 | last post by:
I need immediate help in writing a function program. I have to write a program in functions and use array to store them. I am not familiar with functions and i tried to create it but i fails to...
0
by: ashishbathini | last post by:
Hi guys here is my problem ... this is the source code I Have , honestly I hav no idea how it works bcos its too complicated for me .... but my problem is ... i hav a freq comonent in it .......
9
by: C#_Help_needed | last post by:
I need help with the following question. THANKS :) Write a program in c# that takes in a directory as a command line parameter, and returns the longest repeated phrase in ALL text files in that...
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: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.