Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Encoding and decoding information can save memory space and speed transmission of data. Waitstaff at ice cream shops often encode orders to reduce writing and

Encoding and decoding information can save memory space and speed transmission of data.

Waitstaff at ice cream shops often encode orders to reduce writing and speed up customer service.

Develop a program that asks a user for a single input -- where the first two characters is a flavor of ice cream in the following shorthand code and the last characters are the number of scoops for the type.

Code Ice Cream Flavor
CH Chocolate
CC Chocolate Chocolate Chip
CM Chocolate Mint
HC Horchata
MC Mocha Chip
RR Rocky Road
SB Strawberry
VB Vanilla Bean

For example, the code for twelve scoops of Chocolate Mint is: CM12. Notice there are no spaces between the code and quantity.

Name the source code file Icecream.java and include all your code in this single file.

Ask the user for the following inputs (and no other input) in this order, as shown in the Example Run below:

A single order code like: CM12 (no spaces allowed!!)

A 'y' or 'n' (without the quotes) for the repeat loop

Also, assume the user enters all the codes with UPPERCASE letters as shown.

Store the order code in a single String variable.

Then use substring() to analyze and process the input string to print a full description of the ice cream order.

Use the length() method so that your program adapts to orders of any size.

What happens if a user wants to order 1000 cones of one flavor, 10,000 etc?

Add a while statement that allows the user to repeat the program by entering a 'y' (without the quotes).

If the user enters an invalid code, display the message, "We don't have that flavor." as shown in the example output.

Your Output Should Look Indentical to the Following (except user input will vary):

Welcome to the Really Cool Ice Creamery! Enter the ice cream order code: CM12 12 Chocolate Mint Another order? (y/n) y Enter the ice cream order code: HC2 2 Horchata Another order? (y/n) y Enter the ice cream order code: XY123 We don't have that flavor. Another order? (y/n) n Your ice cream order will be right up!

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

SQL Server Query Performance Tuning

Authors: Sajal Dam, Grant Fritchey

4th Edition

1430267429, 9781430267423

More Books

Students also viewed these Databases questions