Introduction Encoding and decoding information can save memory space and speed transmission of data. Waitstaff at...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
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("\nEnter the order code: "); 12 13 14 } 15 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("\nEnter the order code: "); 12 13 14 } 15
Expert Answer:
Answer rating: 100% (QA)
import javautilScanner public class Main public static void mainString args Scanner s... View the full answer
Related Book For
Management Accounting Information for Decision-Making and Strategy Execution
ISBN: 978-0137024971
6th Edition
Authors: Anthony A. Atkinson, Robert S. Kaplan, Ella Mae Matsumura, S. Mark Young
Posted Date:
Students also viewed these programming questions
-
Briefly describe ASCII and Unicode and draw attention to any relationship between them. [3 marks] (b) Briefly explain what a Reader is in the context of reading characters from data. [3 marks] A...
-
What is a branch delay slot and why does it arise? [7 marks] How can branch delays be avoided? If a processor exhibited one branch delay slot how would you reorder (and possibly modify) the...
-
Discuss the ways that managed care organizations can infl uence the adoption of new technologies.
-
Refer to the financial information presented in P13.2B for Gum San Ltd., a private company following ASPE. In P13.2B GUM SAN LTD. Income Statement Year Ended December 31, 2018...
-
What are the KKT conditions for nonlinear programming problems of the following form? Minimize f(x) Subject to gi(x) bi, for i = 1, 2, . . . ,m and x 0,
-
In 2014, Air Asia Flight No. 8501 crashed in the Java Sea while flying from Indonesia to Singapore. The crash resulted in the deaths of all passengers and crew on board. The plane involved in the...
-
(Comprehensive Problem: Issuance, Classification, Reporting) Presented below are four independent situations. (a) On March 1, 2011, Wilke Co. issued at 103 plus accrued interest $4,000,000, 9% bonds....
-
1) Show a calculation of both the speed and the acceleration of the stopper for the 4 Newton trial. SHOW YOUR WORK BELOW! 2) Make 2 graphs: a. Force versus speed. b. Force versus speed squared. c....
-
Oasis Co., a U.S. shareholder, owns 100% of Shack Co. and 100% of Studio Co., both CFCs. Shack Co. has $300,000 of gross income, of which $50,000 is effectively connected income, and $30,000 is...
-
The magnetic fields of Earth, Jupiter, and Neptune are each generated by a different conducting substance. a) List the conducting substance in each planet that is responsible for generating its...
-
Is there recapture of depreciation when like- kind exchanges of Section 1245 and Section 1250 property occur? Explain.
-
Debbie Davis and Elizabeth Engels exchanged like-kind business buildings. Debbie had an adjusted basis of $120,000 in her property (fair market value is $150,000). Elizabeth's property had an...
-
When considering the cash versus the accrual method of accounting: a. Is there any type of business that must be on the cash method? b. Is there any type of business that must be on the accrual...
-
Linda Loren transfers an apartment building with an adjusted basis of $150,000 and a fair market value of $240,000 for Carol Comb's apartment building (adjusted basis $140,000) with a fair market...
-
Section 1250 recapture provisions apply to all of the following except: a. Residential real property b. Government-financed housing c. Low-income housing d. ACRS nonresidential real property...
-
break down the formulas in the variance descriptions: Variable overhead Expenses $ 200,000 $ 198,000 $ 292,500 Fixed overhead Expenses $ 265,000 $ 247,500 $ 365,625 Units Produced 65,000 44,000...
-
Quadrilateral EFGH is a kite. Find mG. E H <105 G 50 F
-
What are some critical dimensions along which to measure regulatory and social processes in the operating processes part of the Balanced Scorecards process perspective?
-
1. What is an extrinsic reward? 2. What is a cash bonus?
-
Characteristics of a MACS: ethical framework List and describe the hierarchy of ethical considerations.
-
Two-dimensional surfaces that can be made by rolling up a sheet of paper are called developable surfaces. Find the geodesic equations on the following developable surfaces and solve the equations....
-
Using Euler's equation for \(y(x)\), prove that This equation provides an alternative method for solving problems in which the integrand \(f\) is not an explicit function of \(x\), because in that...
-
The time required for a particle to slide from the cusp of a cycloid to the bottom is \(t=\pi \sqrt{a / 2 g}\). Show that if the particle starts from rest at any point other than the cusp, it will...
Study smarter with the SolutionInn App