Computer Science Homework Solutions
Problem
#173957

Java: How to Program

Choose 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 item 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.

I forgot some important information and I have a response for this, but I could not edit it since an OTA had already signed it out.  I tried to delete the original submission, but it would not let me.

I chose cd's as the the product.

Here is the information:

For this assignment you will be creating a new program that meets the following criterion:

1.       The Inventory Program application should contain a class named 'Product' that holds the item number, the name of the product, the number of units in stock, and the price of each unit. This class will be saved in a separate file named Product.java (Hint: this means you should also call your class "Product".)

2.       The constructor for this class will have 4 arguments: the item number, the name of the product, the number of units in stock, and the price of each unit.

3.       In the main method you will create 3 new objects of the class 'Product' (one at a time) each with different values and pass those values to the constructor. (You will not ask the user for this data and you will not use a loop nor will you use an array.)

4.       You will also create a calculate inventory method that will calculate the value of each item by multiplying the number of units in stock by the price of each unit.

Don't forget to create the get/set methods for each of your variables.

5.       You will also need to display the inventory value. You will display the inventory from the "main method" (this means that your 'print' statements will be in the "main method"). Be sure that you use the appropriate format specifiers to display unit price and the value of the inventory for the item as currency. Each item's inventory information should be displayed on only 1 line. Appropriate column headings should also be used.

6.       You will be submitting two files for this assignment. The file that contains the main method should have a class declaration for InventoryPart1 and the file name should be InventoryPart1.java. The class file should be named Product.java which means that your class will also be named Product.  

Note: you will be using this same Product class for subsequent assignments.

7.       You must turn in two files:

InventoryPart1.java
Product.java

Solution
What is this?
By OTA - Overall OTA Rating
Yupei Xiong, PhD - 4.8/5
Purchase Cost Now
$2.19 CAD (was ~$15.96)
Included in Download
  • Plain text response
  • Attached file(s):
    • InventoryPart1.java
    • Product.java
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • Java: How to Program - 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, ...
  • Examples of correct Variable declaration in C++ - Which of the following variable declarations are correct? If a variable declaration is not correct give the reason(s) and provide the correct variable declaration. n = 12; //Line 1 ...
  • HELP WITH THESE THREE QUESTIONS - 1. Why declaration of a variable is considered to be an important (and sometimes required) part of good programming practice? 2. Name few languages that allow use of variables without even declari ...
  • Data Structures C++ - Consider the following statement: class strange { . . . }; a. Write a statement that shows the declaration in the class strange to overload the operator >>. b. Write a statement that shows ...
  • Java Code - I need assistance in remarking the enclosed Java Code high-lighting, things like code layout, use of variable names, general readability and understandability.
Browse