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
-
3- 2014-T6 alamndan retilmi silindirik bir mil muylu ksmndan 50 kN'luk tam deiken ekme-basma yklerinin etkisi altndadr. 745 dev/dak sabit hzda gnde 8 saat alan milin bir sonraki (28 gn sonra) bakm...
-
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...
-
Test the claim about the difference between two population means 1 and 2 at the level of significance a. Assume the samples are random and independent, and the populations are normally distributed....
-
In which ways can word-of-mouth communication influence the effectiveness of a promotion mix for a product?
-
Network Technologies manufactures capacitors for cellular base stations and other communication applications. The companys July 2014 flexible budget shows output levels of 7,000, 8,500, and 10,500...
-
Owl Supermarkets Inc. (O-S-I) is a grocery store based in Houston, Texas. The company began its operations on January 1, 2021. During its first quarter of operations (January through end of March) in...
-
Describe a representation that could be used in a program to solve analogy problems like that in Figure 7.29. This class of problems was addressed by T. G. Evans (1968). The representation must be...
-
Summarise the principles and concepts of strategic management, including mission statements, vision statements core values, organizational objectives, internal, external and global environments
-
On March 28,1994 - a medical examiner viewed the body of Ronald Opus, and concluded that he died from a shotgun wound to the head. Mr. Opus had jumped from the top of a ten -story building intending...
-
Your mother was diagnosed with Alzheimer's last year.At first it wasn't too bad, but now your Mom confuses the identity of her son, sometimes mistaking him for her husband who passed away two (2)...
-
Bob and Jan are married. They have three children: Emily, Jake and Hanna. Emily has a son, Parker, and Hanna has two sons, Brad and James. Bob died first followed by Jan. Bob's will left everything...
-
Evaluate the function k(x) = x+1 for the given values of x. Write exact answers in simplified form. If the function is undefined at the given value of x, use the "Undefined" button. (a)k(5) (b)(-7)...
-
Using your own words and without quoting from the text, what is the general rule in this case? What is the specific rule? keep it simple and short. No more than fifty words. Read, then brief the...
-
A firm has initial endowment of $6 million. It has investment opportunities to invest $9 million that gives an average return of 40%. The current opportunity cost of capital for the firm is 12%....
-
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.
-
Polecat Corporation is considering beginning drilling operations in three separate fields. Polecat decides to analyze these fields using a 13% discount rate. The estimated cash flows for each field...
-
Define the following: asset retirement obligation retirement accretion promissory estoppel legally enforceable obligation obligating event
-
Define the following: impairment asset group traditional present value approach expected present value approach
Study smarter with the SolutionInn App