Question: Define a class named GroceryItem. Include private fields that hold anitems stock number, price, quantity in stock, and total value. Write apublic function named dataEntry()

Define a class named GroceryItem. Include private fields that hold anitems stock number, price, quantity in stock, and total value. Write apublic function named dataEntry() that calls four private functions. Threeof the private functions prompt the user for keyboard input for a value forone of the data fields stock number, price, and quantity in stock. Thefunction that sets the stock number requires the user to enter a valuebetween 1000 and 9999 inclusive; continue to prompt the user until avalid stock number is entered. The functions that set the price andquantity in stock require non-negative values; continue to prompt theuser until valid values are entered. Include a fourth private function thatcalculates the Groceryltems total value field (price times quantity instock). Write a public function that displays a GroceryItems values.Finally, write a main() function that declares a GroceryItem object,assigns values to its fields, and uses the display function. Save the file asGrocery.java.b) Write a main() function that declares an array of 10 Groceryltemobjects. Assign values to all 10 items and display them. Save the file asGrocery2.java.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!