Here is my Inventory program for my Java class....
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!
Code:
//Inventory.java
//Class created to store item information for Inventory purposes
//Created November 15, 2006
//Modified November 29, 2006
//Audrey A. Paige
//IT315
class Product
{
private String name; // class variable that stores the item name
private double number; // class variable that stores the item number
private long stockQuantity; // class variable that stores the quantity in stock
private double price; // class variable that stores the item price
public Product() // Constructor for the Supplies class
{
name = "";
number = 0.0;
stockQuantity = 0L;
price = 0.0;
}
public Product(String name, int number, long stockQuantity, double price) // Constructor for the Supplies class
{
this.name = name;
this.number = number;
this.stockQuantity = stockQuantity;
this.price = price;
}
public void setItemName(String name) // Method to set the item name
{
this.name = name;
}
public String getItemName() // Method to get the item name
{
return name;
}
public void setItemNumber(double number) // Method to set the item number
{
this.number = number;
}
public double getItemNumber() // Method to get the item number
{
return number;
}
public void setStockQuantity(long quantity) // Method to set the quantity in stock
{
stockQuantity = quantity;
}
public long getStockQuantity() // Method to get the quantity in stock
{
return stockQuantity;
}
public void setItemPrice(double price) // Method to set the item price
{
this.price = price;
}
public double getItemPrice() // Method to get the item price
{
return price;
}
public double calculateInventoryValue() // Method to calculate the value of the inventory
{
return price * stockQuantity;
}
}//end class Product
public class Inventory
{
// main methods begins execution of java application
public static void main( String args[])
{
Product p = new Product("Pencil", 5460, 125, 1.5);
System.out.printf("\n\nItem Name:%s\n",p.getItemName()); //display item name
System.out.printf("Item Number:%s\n",p.getItemNumber()); //display item number
System.out.printf("Quantity in Stock:%s\n",p.getStockQuantity()); //display quantity in stock
System.out.printf("Item Price:$%.2f\n",p.getItemPrice()); //display item price
System.out.printf("Value of Inventory:$%.2f\n",p.calculateInventoryValue()); //display total value of inventory for this item
} // end main method
}//end class Inventory
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!
Comment