Programming Homework Help. UCLA Java Question
I’m working on a java question and need guidance to help me learn.
Note: Creating multiple Scanner objects for the same input stream yields unexpected behavior. Thus, good practice is to use a single Scanner object for reading input from System.in. That Scanner object can be passed as an argument to any methods that read input.
Note: Accessor refers to getters and mutator refers to setters.
Write the ItemToPurchase class per the following specifications:
- Private fields
- string itemDescription – Initialized in default constructor to “none”
- Parameterized constructor to assign item name, item description, item price, and item quantity (default values of 0).
- Public member methods
- setDescription() mutator & getDescription() accessor
- printItemCost() – Outputs the item name followed by the quantity, price, and subtotal
- printItemDescription() – Outputs the item name and description
Ex. of printItemCost() output:
Bottled Water 10 @ $1 = $10
Ex. of printItemDescription() output:
Bottled Water: Deer Park, 12 oz.
Write a class called TestItemToPurchase. In the main create a few object
Of ItemToPurchase and show its methods works. When you run your code copy and past the output in report.txt.
Submit three files ItemPurchase.java,TestItemToPurchase.java and report.txt