Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

3.14 part 3: Grocery List 3.14 Ch 3 Program, part 3: Grocery List This program is a take on the classic programming assignment of creating

3.14 part 3: Grocery List

image text in transcribedimage text in transcribedimage text in transcribed

3.14 Ch 3 Program, part 3: Grocery List This program is a take on the classic programming assignment of creating a grocery list. Your task is to take the store, the food or drink item, and the amount for each item as input and create a grocery list string that can be displayed to the user. For example, the parts in bold were entered by the user. Once read, the user input will be modified to fit the following rules: 1. Store name: no leading or trailing whitespace; all characters should be upper case; the only String that may contain a space character (can be multiple words). 2. All food and drink: no leading or trailing whitespace; all characters should be lower case. Below is an example of input, in bold, for the grocery list program. Each amount/weight in the input are followed by their corresponding food/drink (amount1 corresponds to food1, amount3 corresponds to drink, etc). Store: the Farmer's Market amount1: 5 food1: Apples amount2:12 food2: Eggs amount3:3 drink: milk weight1: 1.5 food3: CHEESE weight2:3 food4: potatoes The resulting grocery list is: Grocery List for Bucky Badger I am going to THE FARMER'S MARKET to get: 5 apples 12 eggs 3 gallons of milk 1.5 pounds of cheese 1.5 pounds of cheese 3.0 pounds of potatoes Note: there should always be 5 items in the grocery list, with the third item in units of gallons, and the fourth and fifth items in units of pounds. Requirements: Your main method should contain all input code (e.g., Scanner instance) and have 11 user prompts inputting values with nextInt(). nextDouble, next(), and nextLine(). All output code (e.g., print statements) must be in the main method as well. The makeGroceryList method takes the arguments passed in and prepares the entire grocery list, using all the 11 parameters and returning one long String. You do not need to use the above grocery list. You can try out your own input values. Your grocery list must contain your name as you entered it in the file header comments. It should be a string literal and not passed in as a parameter. For example, at the start of your grocery list "Grocery List for Bucky Badger..." The method stub for makeGroceryList is: /* * * Returns a single String that is formatted as a grocery list that contains all * 11 parameters. You must include your name in the list as a string literal * (don't pass in your name as a parameter). Your name must match the name within * the File Header Comment. There are no input or output statements in this method. All input should already be done in main (when the user is prompted), and all output should be done in main after this method * returns. * DO NOT MODIFY THE ORDER OF PARAMETERS IN THE METHOD HEADER. If you do, * you may not pass the automatic tests that we use to grade your submission. * @param store @param amounti * @param amount2 * @param amount3 * @param weight1 + anayam Weih+2 you may not pass the automatic tests that we use to grade your submission. * @param store @param amounti * @param amount2 * @param amount3 * @param weighti * @param weight2 * @param foodi * @param food2 * @param food3 * @param food4 * @param drink * @return A grocery list that contains all 11 parameters and your name. */ public static String makeGroceryList (String store, int amounti, int amount2, int amount3, double weighti, double weight2, String foodi, String food2, String food3, String food4, String drink) { //FILL IN BODY Note that you may change the makeGroceryList parameter names to be more meaningful, but be sure to keep the order and data types the same. It is good practice to test different combinations of input with your method, but note that we will test your method using specific input for this lab. When calling makeGroceryList, the arguments passed are by position (the order in which they show up as parameters in the method header), so the parameter names do not matter outside the method. Also note that the grocery list should NOT end with a newline character. A tutorial on using the Scanner is provided here: Learn to use Scanner. Before turning in, remember to Style and Comment following the course standards CS 200 Style. Created by Elliott Janssen Saldivar. Reviewed and unit tested by Rami Dahman. 1/30/20 - Amos removed required white-space from output test since it wasn't obvious that this was required from the test feedback 2/10/20 - Jim If you are having difficulty passing tests consider comparing output using a tool such as DiffChecker. Also, added "Another comparison:" to the output of test 2

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

Machine Learning And Knowledge Discovery In Databases European Conference Ecml Pkdd 2018 Dublin Ireland September 10 14 2018 Proceedings Part 1 Lnai 11051

Authors: Michele Berlingerio ,Francesco Bonchi ,Thomas Gartner ,Neil Hurley ,Georgiana Ifrim

1st Edition

3030109240, 978-3030109240

More Books

Students also viewed these Databases questions