Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Congratulations on being provided your first programming task at the grooery store chain where you were recenty hired as a computer programmer to create a

image text in transcribedimage text in transcribed

Congratulations on being provided your first programming task at the grooery store chain where you were recenty hired as a computer programmer to create a Grocery Caloulator. You will begin your very first ooding asaignment this module. Your project wll incrementally evolve during the next several modules. Your first task is to create the Grocery class as outined in the Module 01 UML diagram, and instances of the Grocery class as oulined below Your task this module is to do the tollowing: Grocery Class: . In a new project create the Grocery class and its .Use appropriate accoess modifiers in your state and method declarations. The UML Diagram for the Grocery class is replicated below Code constructors, got0 and sot0 methods, and a toString0 method. Override the toString() method using appropriate syntax. .In the toString0 overridden method, convert the name attributefield to UPPER CASE using the atribute.toUpperCase) method. .Do not code set() methods for any attnibutes that are calculated within the Grocery class. You may code get) methods as appropriate . Code a constructor that takes no parameters but sets values to zero or the like. . Code parametenzed constructor that ccepts namo, quantity, and oost as parameters. reate orma ted ut i the to tring methods to ist al attributes in an eas 40eed format with hea in such as 1, 2, 3) nat are calculated and assigned when creating object instances. dolar sign ormat n two de mal place fom at fo doubles, appro nate line b eaks, separator nes between output o object nstances, and ob ect item numbers Class including the Main) Method: .In the same project in which you created the Grocery class above, create a driver class that includes a Main) method that uses the Grocery class. .Include appropriate package import declarations as needed Input: Use a loop to garner user input from the console using java, udi Scanner and place te nut into a fixed-lengtharray Prompt the user with a menu of two choices such as: o -(1) Input a Grocery item, .(-1) End user input e The loop willi then prompt users for the grocery name, quantihy, and cost at a unit or individual level when option 1 is entered terminate user inputilooping when option -1 is entered e Use a technique to signal the end of input such as a sentinel. Data Structure Storage: Code your dlass containing the Main) method to store user input in a fixed-Jength array while the program is execuing. Consider seting the array length to exacty the number of required objects input by the user Data Validation: o Include the following validation in separate methods both returning Boclean results -Cost must be 0. Quantty must be1 For invalid datn, simply output a message to the oonsole informing the user of the impeoper data entered and do not create a Grocery objeat instance o Only create a Grocery object instance when the data is considered valid o Use System.out print to echo back to the user the data they input once validated. o Cal a method to output an appropriately formatted heading including .Output to the console while executing the program .Output to the console after the user terminates input - A greeting. Your Name. Your Class, ModuleWeek, and Assignment. Date/Time stamps - o Cal the toString method for each Grocery objeat instance to output the name, quantity, cost, axtondodCoat, and titlos/headings for each using formatting o Cal a method to output the total ExtendedCost, totalQuantity, and the average cost (totalExtendedCost totalQuantity) one time at the end of the program using appropriate fomatting and formatting that separates this output from the other output Other .Run your program with at least three Grocery object instances varying the attnibute values. .Observe proper commenting/documentation techniques. Include clearly written comments/documentation to explain the purpose of major blocks of code. As needed/appropriate, include additional levels of comments/documentation detal to help you understand your code and logic as well as to help your reader understand the same. Observo proper naming conventiona for classos, attributes, mothods, otc

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions