Details of this Paper

Inventory Program part 1 and part 2




//;// Inventory keeper for torque tools;import java.util.Scanner, // program uses class Scanner;class ProductInfo // class to store product information;ProductInfo(int itemNumber, String itemName, int stockQty, double priceEach) // constructor for product info;num = itemNumber;name = itemName;stock = stockQty;price = priceEach;public int getNum();return num;public String getName();return name;public int getStock();return stock;public double getPrice();return price;public double getInventoryTotal();return price * stock;private int num, // product's item number;private String name, // product's item name;private int stock, // number of item in stock;private double price, // price each of item;// end class ProductInfo;class SFInventoryPt1;private String ProductInfo, // call class product info;// main method begins execution of Java application;public static void main (String args[]);//create Scanner to obtain input from command window;Scanner input = new Scanner(;int num, // product's item number;int stock, // number of items in stock;double price, // price each of item;ProductInfo product, // product information instance;System.out.println(), // blank line;System.out.print("Enter the item name of the product, or STOP to quit: "), // prompt;String name = input.nextLine(), // read item name from user or quit;// loop until sentinel value read from user;while (!name.equalsIgnoreCase ("stop"));System.out.print("Enter the item number of the product: "), // prompt;num = input.nextInt(), // read item number from user;while (num <=0) //loop until item number is positive;System.out.println ("Item number must be positive. Please re-enter item number: "),//prompt user to re-enter item number;num = input.nextInt(), // read item number;//end while;System.out.print("Enter the quantity of product in stock: "), // prompt;stock = input.nextInt(), // read stock quantity from user;while (stock <0) //loop until stock is positive;System.out.println ("Quantity in stock can not be less than zero. Please re-enter the quantity in stock: "),//prompt user to re-enter quantity in stock;stock = input.nextInt(), // read stock quantity from user;//end while;System.out.print("Enter the price of the product: "), // prompt;price = input.nextDouble(), // read item price from user;while (price <=0) //loop until price is positive;System.out.println ("Product price must be positive. Please re-enter the price of the product: "),//prompt user to re-enter product price;price = input.nextDouble(), // read item price from user;//end while;product = new ProductInfo(num, name, stock, price), // initialize ProductInfo variables;System.out.println(), // blank line;System.out.printf("Item Name: %S\n", product.getName());System.out.printf("Item Number: %s\n", product.getNum());System.out.printf("Qty. in Stock: %s\n", product.getStock());System.out.printf("Price Each: $%.2f\n", product.getPrice());System.out.printf("Total Value in Stock: $%.2f\n", product.getInventoryTotal());System.out.println(), // blank line;System.out.print("Enter the item name of the product, or STOP to quit: "), // prompt;name = ";while (name.equals(""));name = input.nextLine(), // read new product name from user or quit;//end while;System.out.println(), // blank line;System.out.println("Good Bye!"), // exit message;// end method main;// end class SFInventoryPt1;This is where my trouble starts. I now need to modify the above code to meet these assignment requirements;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


Paper#70025 | Written in 18-Jul-2015

Price : $27