Hello,
I am having trouble with my inventory program. I made the first part last week and thought I did a good job. Come to find out I did not and the feedback I recieved from my instructor was not very helpful. Is there anyone that can help me fix my error for part 1 so I can continue to make part 2? My feedback was that I did not call the class method to calculate the value of the inventory. Here is my code:
`
* Public class: Inventory1.java
* Program displays inventory.
*/
/** Inventory1.java
* Author Melissa Hall
* IT215 Java
* 10/25/2014
*/
import java.text.NumberFormat;
import java.util.Locale;
import java.util.Scanner;
class Pizza {
private String itemNumber;// Item number
private String productName;// Product name
private int productInStock;// Number of product in stock
private double productPrice;// Price per product
private double totalInventoryValue;// Total inventory value
//Default constructor
public Pizza(){
itemNumber = "";
productName = "";
productInStock = 0;
productPrice = 0.0;
totalInventoryValue = productInStock * productPrice;
}
// Consturctor
public Pizza( String number, String name, int inStock, double price )
{
itemNumber = number;
productName = name;
productInStock = inStock;
productPrice = price;
totalInventoryValue = productInStock * productPrice;
}//End constructor
public String getItemNumber(){
return itemNumber;
}
public void setItemNumber(String number){
this.itemNumber = number;
}
public String getProductName(){
return productName;
}
public void setProductName(String name){
this.productName = name;
}
public int getProductInStock(){
return productInStock;
}
public void setProductInStock(int inStock){
this.productInStock = inStock;
}
public double getProductPrice(){
return productPrice;
}
public void setProductPrice(double price){
this.productPrice = price;
}
public double getTotalInventoryValue(){
return totalInventoryValue;
}
public void setTotalInventoryValue(double value){
this.totalInventoryValue = productInStock * productPrice;
}
}
public class Inventory1 {
public static void main(String[] args)
{
System.out.println( "Welcome to the inventory program" );
// create a Scanner to obtain input from the command window
Scanner input = new Scanner( System.in);
String itemNumber;// Item number
String productName;// Product name
double productPrice;// Product price
int productInStock;// productInStock
double totalInventoryValue;// Total inventory value
{
System.out.println( "Enter the item number: "); // Prompt user
itemNumber = input.nextLine(); // read user input
System.out.println( "Enter the product name: ");// Prompt user for product name
productName = input.nextLine();
System.out.print( "Enter the product price: ");// Prompt user for the product price
productPrice = input.nextDouble();
System.out.print( "Enter the total products in stock: ");// Prompt user for total products in stock
productInStock = input.nextInt();
totalInventoryValue = productInStock * productPrice;
}
Pizza pizza = new Pizza();
NumberFormat nf = NumberFormat. getCurrencyInstance(Locale.US);
//Use method from class Pizza to output inventory
{
System.out.println(" Item number is " + itemNumber);
System.out.println(" The product name is " + productName);
System.out.println(" The number of products in stock are: " + productInStock);
System.out.print(" The price of each product is: ");
System.out.println(nf.format(productPrice));
System.out.print(" The inventory value is: ");
System.out.println(nf.format(totalInventoryValue));
}// End Main class
}
}
`I just recieved the feedback yesterday and the next part is due today, so please if someone can help me please do. Thanks.