Assignment #13

Instructions

  1. Write a Java application as described in assignment #12.
  2. For assignment #13, add the following code to assignment #12:
    1. In the GroceryItem.java file, add set() and get() methods for each data field. For example, create methods setName(), getName(), setPrice(), getPrice(), setCount(), and getCount().
    2. Change the name of the client program from LastNameFirstName12.java to LastNameFirstName13.java.
    3. In the LastNameFirstName13.java file, use the three get() methods to get the name, price, and count of the first grocery item, and display each separately.
    4. Use set() to change the data fields of the second grocery item.
    5. For the remaining three grocery items, use getCount() and setCount() to increase the count by 100. To do this, create an Integer variable. Store the count in the variable by using getCount(). Add 100 to the variable. Then, use setCount() and the variable as a parameter to change the count.

Example Output

name		price		count
bananas		$0.99		20
oranges		$2.99		5
garlic		$3.99		10
grapes		$9.99		2
papayas		$4.99		6

get() the data fields of the first grocery item
name = bananas
price = 0.99
count = 20

set() the data fields of the second grocery item
name		price		count
APPLES		$2.55		88

For the remaining three grocery items, use getCount() and setCount() to increase the count by 100
name		price		count
garlic		$3.99		110
grapes		$9.99		102
papayas		$4.99		106

Click to validate the HTML code

Click to validate the CSS code