Share
Explore BrainMass

Java Payroll Program to Create an Inventory

Choose a product that lends itself to an inventory (for example, products at your workplace, office supplies, music CDs, DVD movies, or software).

? I need to 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.

?I need to 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.

You need to create two files. The first contains the main method and the second is a class file

Instead of having a compute average method on the class file, you will have compute value method.

You would have getter and setter methods for these variables.
You would also have a computeValue method.

For this problem I want to use office supplies such as Pencils, pens, notepad, Highlighters, folders etc..

Solution Preview

I have attached the files inventory.java and inventoryMain.java in a compressed file. The first one is the class and has many getters and setters. It also has two methods valueOfInventory() and showInventory().

/**
* Created by IntelliJ IDEA.
* User: Mahmood
* Date: Sep 13, 2006
* Time: 1:48:41 AM
* To change this template use File | Settings | File Templates.
*/
public class inventory {
private int itemNum;
private String name = new String();
private int units;
private double price;

// All getters and setters
public int getItemNum() {
return itemNum;
}

public void setItemNum(int itemNum) {
this.itemNum = itemNum;
}

public String getName() {
return name;
}

public void setName(String name) {
this.name = name;
}

public int getUnits() {
return units;
...

Solution Summary

A) 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.

B) 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.

$2.19