Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Introduction Encoding and decoding information can save memory space and speed transmission of data. Waitstaff at ice cream shops often encode orders to reduce
Introduction 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 orders using codes like those in the table below. Flavor Codes Code Flavor C Chocolate CC Chocolate Chip CM Chocolate Mint H Horchata MC Mocha Chip RR Rocky Road S Strawberry V Vanilla Lab Specifications 1. Develop a program that asks a user for a single input where the first one or two characters is a type of ice cream in the shorthand code listed in the table above, followed by the number of scoops. For example, the code for 2 Mocha Chip scoops is: MC2. Notice there are no spaces between the code and quantity. The order code may be upper or lower case letters and the number of scoops can be any amount greater than zero. 2. Store the order code in a single String variable. Then use String methods we have covered to decode the order: charAt(), compareTo(), compareToIgnoreCase(), equals(), equalsIgnoreCase(), length(), toLowerCase(), or toUpperCase(). Do NOT use other string methods. 3. Make use of if, else-if and else statements and clauses in your program. 4. If the user enters an invalid code, display the message: "We don't have that flavor." as shown in the Example below. 5. If the user enters a quantity that is more than 99, display the error message: "We don't have sufficient ice cream in stock for that order." as shown in the Example below. 6. No other error checking is required. 7. Add a file comment block at the top of the code with your name, the course and lab number. 8. As with all projects, only use techniques we have covered so far in the course and meet all academic integrity requirements of the syllabus. Welcome to the Really Cool Ice Creamery! Enter the order code: C2 2 Chocolate scoops Welcome to the Really Cool Ice Creamery! Enter the order code: RR33 33 Rocky Road scoops Welcome to the Really Cool Ice Creamery! Enter the order code: H123 We don't have sufficient ice cream in stock for that order. Welcome to the Really Cool Ice Creamery! Enter the order code: XY12 We don't have that flavor. where the user enters the values shown in bold-italics (for emphasis) to produce the output. User input only appears if entered in a console or terminal like Develop mode or Eclipse. Hint: You can use Unicode to check if a character is numeric (i.e. one of the characters from '0' to '9'). To do so, write an if statement to check if a char falls between '0' and '9'. See a Unicode table here Hint 2: Make sure to download the starter code. 307128.2320112.qxdzay7 LAB ACTIVITY 5.1.1: LAB 8: Ice Cream Orders Downloadable files IceCream.java Download 0/10 1 import java.util.Scanner; 2 3 public class IceCream { public static void main(String[] args) { IceCream.java Load default template... 4 5 string type = ""; 6 string qty = "";" 7 boolean invalidLen = false; 8 boolean invalidCode = false; 9 10 11 System.out.println("Welcome to the Really Cool Ice Creamery!"); System.out.print(" Enter the order code: "); 12 13 14 } 15
Step by Step Solution
★★★★★
3.34 Rating (160 Votes )
There are 3 Steps involved in it
Step: 1
import javautilScanner public class Main public static void mainString args Scanner s...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started