Answer to Question #274397 in Java | JSP | JSF for maka

Question #274397

Take your Array of InventoryItems from assignment 11 and put them in an ArrayList to show how to use lists. Print all the InventoryItems in the ArrayList for the user.

Ask the user for a ItemID, Description, and Price and make a new InventoryItem and add it to the Arraylist. Print all the InventoryItems in the ArrayList for the user to show that you added one.

Remove 2 InventoryItems from the ArrayList and print all the InventoryItems in the ArrayList for the user a last time to show that you can dynamically remove them.

Program 2

Make a 2D array to hold saleAmounts from the user for a store that has 3 departments and 4 salespeople. Put zeros in all 12 spots in the array with an initialization list or through other code.

Ask the user 3 times for a department number, salesperson number, and sale amount. Put this sale amount into the array using the department number as a row and the salesperson number as a column.

Print the 2D array for the user with row totals and column totals.


1
Expert's answer
2021-12-03T06:28:12-0500
public class Main {
  public static void main(String[] args) {
    final ArrayList<InventoryItem> items = new ArrayList<InventoryItem>
    
  }
  public InventoryItem readItem() {
    // TODO: implement
    return new InventoryItem();
  }
}
class InventoryItem {
  private int itemID;
  private String decsription;
  private double price;
  public InventoryItem(int ID) {
    this.itemID = ID;
    this.description = "";
    this.price = 0;
  }
  public InventoryItem(int ID, String desc, double price) {
    this.itemID = ID;
    this.description = desc;
    this.price = price;
  }
  public int getItemID() { return itemID; }
  public String getDescription() { return description; }
  public double getPrice() { return price; }
  
  public void setItemID(int ID) { this.itemID = ID; }
  public void setDescription(String desc) { this.description = desc; }
  public void setPrice(double price) { this.price = price; }
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS