Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

create grocery list: Store name: no leading or trailing whitespace; all characters should be upper case; the only String that may contain a space character

create grocery list:

  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.

Examples:

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 for *Name* I am going to THE FARMER'S MARKET to get: 5 apples 12 eggs 3 gallons of milk 1.5 pounds of cheese 3.0 pounds of potatoes 

Note: there should always be 5 items in the grocery list, third is gallons, fouth and fifth are pounds

  • 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 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 *Name* ......"

image text in transcribed

ublic class Grocerylist { public static String makeGroceryList(String store, int amounti, int amount2, int amount3, double weight, double weight2, String foodi, String food2, String foods, String food4, String drink) { //FILL IN BODY public static void main(String[] args) { //FILL IN BODY System.out.println("Grocery List for......"); System.out.println("I am going to *Store* to get: "); System.out.println()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access with AI-Powered 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

Students also viewed these Databases questions