I'm stuck. This is what I have written so far, but I don't know how to set up for a method call to prompt for the total. I need the individual totals for all items in the array to be added to get a total cost and it needs to be displayed at the end of the program. Please, any advice is helpful. I have to be to work soon and need to turn it in before I go. Thanks
MAIN FILE
package inventory2; import java.util.Scanner; public class RunApp { public static void main(String[] args) { Scanner input = new Scanner( System.in ); Items theItem = new Items(); int number; String Name = ""; System.out.print("How many items are to be put into inventory count?: "); number = input.nextInt(); input.nextLine(); Items[]inv = new Items[number]; for(int count = 0; count < inv.length; ++count) { System.out.print("\nWhat is item " +(count +1) + "'s name?: "); Name = input.nextLine(); theItem.setName(Name); System.out.print("Enter " + Name + "'s product number: "); double pNumber = input.nextDouble(); theItem.setpNumber(pNumber); System.out.print("How many " + Name + "s are there in inventory?: "); double Units = input.nextDouble(); theItem.setUnits(Units); System.out.print(Name + "'s cost: "); double Price = input.nextDouble(); theItem.setPrice (Price); inv[count] = new Items(Name, Price, Units, pNumber); input.nextLine(); System.out.print("\n Product Name: " + theItem.getName()); System.out.print("\n Product Number: " + theItem.getpNumber()); System.out.print("\n Amount of Units in Stock: " + theItem.getUnits()); System.out.print("\n Price per Unit: " + theItem.getPrice() + "\n\n"); System.out.printf("\n Total cost for %s in stock: $%.2f", theItem.getName(), theItem.calculateTotalPrice()); System.out.printf("Total Cost for all items entered: $%.2f", theItem.calculateTotalPrice()); //i need to prompt for output to show total price for all items in array } } } 2ND CLASS
package inventory2; public class Items { private String Name; private double pNumber, Units, Price; public Items() { Name = ""; pNumber = 0.0; Units = 0.0; Price = 0.0; } //constructor public Items(String productName, double productNumber, double unitsInStock, double unitPrice) { Name = productName; pNumber = productNumber; Units = unitsInStock; Price = unitPrice; } //setter methods public void setName(String n) { Name = n; } public void setpNumber(double no) { pNumber = no; } public void setUnits(double u) { Units = u; } public void setPrice(double p) { Price = p; } //getter methods public String getName() { return Name; } public double getpNumber() { return pNumber; } public double getUnits() { return Units; } public double getPrice() { return Price; } public double calculateTotalPrice() { return (Units * Price); } public double calculateAllItemsTotalPrice() //i need method to calculate total cost for all items in array { return (TotalPrice ); } }