Question
Assume youve been assigned the task to create tickets for Disney World based on which theme park the customer wants to visit and the number
Assume youve been assigned the task to create tickets for Disney World based on which theme park the customer wants to visit and the number of days. Create a program that prompts the user to enter two values a character and a number and then displays a randomly generated ticket based on those two values. The character represents the theme park and the number represents the number of days. For this assignment, the following characters will be used to denote the theme park: A: Animal Kingdom E: Epcot H: Hollywood Studios M: Magic Kingdom Number of days: must be between 1 and 7 Once theme park and number of days are BOTH obtained, generate a random ticket for the selected theme park using these given patterns: Theme Park Description Template Example Animal Kingdom 2 digits, a dash, 4 digits, a dash, letters AK ##-####-AK 19-2445-AK Epcot 5 digits, 2 dashes, 2 letters, 2 dashes, letter E #####--XX--E 8080--WP--E Hollywood Studios 3 letters, a space, 3 digits, a space, letters HS XXX ## HS LYF 817 HS Magic Kingdom 1 digit, a space, 3 letters, a space, letters MK # XXX MK 2 IMP MK # - represents a number X represents a letter Specifications Write code that: Prompts user for theme park and number of days This information will be entered on the same line with a space between the two values (E 5) Reads theme park as a string (e.g. user enters E for Epcot) o See details below in Must Do and Tips Reads number of days as an integer (e.g. user enters 5 for a 5 day ticket) Extracts from the string the theme park character (A, E, H, or M) and ensures it is valid If theme park is valid, ensure number of days is valid (1 through 7) After theme park and number of days are validated, generate the random ticket number Display theme park name, randomly generated ticket, and number of days 5. The code must handle user validation for: Theme park o If an invalid theme park is entered, MUST print message and END PROGRAM Number of days o If invalid number of days is entered, MUST print message and END PROGRAM Note: o End program means: once an input error occurs, the program must display an error message and perform no more processing. o For example: If the user enters P 2 when asked for the values, the program must display an invalid theme park error message and complete processing. At this point, your code must NOT process the number of days. See error output examples #3 and #4 below. o Use NESTED IF statements to properly handle errors in user input. An if statement performs a test (say on the theme park character) and if the test fails the else clause executes, displays the error message, and the program terminates. DO NOT use System.exit(0) to exit program if an error occurs DO NOT use break or return statements if an error occurs Using System.exit, return, or break will result in loss of points for correctness The purpose is to learn to write properly nested if-statements. Must Do and Tips Must Do: General Reading user input o The theme park and number of days must be entered on the same line This means both values must be entered before enter key is pressed. o User input for theme park must first be read as a String use the next() method in Scanner class to read theme park character as a String Next extract the character from the string using charAt() method o Your code must accept lower-case or upper-case values for the theme park character Use correct data types and constants o To eliminate magic numbers numbers whose meaning is not known use constants to make the code easier to understand. o Constants must be used for the different theme parks, for example: final char ANIMAL_KINGDOM = 'A'; final char EPCOT = 'E'; Must use nested if-statements for the main structure of the code, not a multiway-if Uses a switch statement to display the number of days
Must Do: Use random method provided in Math class Use the random method in the Math class Math.random() Generate different letters and numbers for each ticket. DO NOT generate one letter or number and use it repeatedly. DO NOT use the class provided by Java called Random. DO NOT create a string of numbers or letters and then randomly get values out of that string. Tip: Play with the random function to learn how it works Use Math.random and the ASCII table in Appendix B to create the necessary values. To create numbers: o You do not need to worry about generating numbers with leading zeros. o You may assume the following: When creating a 1-digit value, the values run between 1 and 9 When creating a 2-digit value, the values run between 10 and 99 When creating a 3-digit value, the values run between 100 and 999 When creating a 4-digit value, the values run between 1000 and 9999 To create letters: o Use the information in the ASCII table in Appendix B o In the ASCII table, A - Z are associated with the numbers 65 90 1st use random number generator to generate numbers in range 65 - 90 2nd cast the random number to a char to create the letter Tip: Use toUpperCase or toLowerCase method in the Character class To write simpler and cleaner code that performs user validation, convert the theme park character to an uppercase value or lowercase value. Now in the if-statement, you only need to test for upper or lower case. Output Your output should look like the following: Output Example #1 Enter theme park character (A,E,H,M) then a space then the number of days (1-7): (A: Animal Kingdom E: Epcot H: Hollywood Studios M: Magic Kingdom) A 1 Values entered when ran program Animal Kingdom: 41-1980-AK (1 Day Ticket) Output Example #2 Enter theme park character (A,E,H,M) then a space then the number of days (1-7): A: Animal Kingdom E: Epcot H: Hollywood Studios M: Magic Kingdom m 5 Magic Kingdom: 5 HDM MK (5 Day Ticket) Output Example #3 Error Invalid Theme Park Enter theme park character (A,E,H,M) then a space then the number of days (1-7): A: Animal Kingdom E: Epcot H: Hollywood Studios M: Magic Kingdom P 2 Invalid input for theme park run program again Output Example #4 - Error - Invalid Ticket Enter theme park character (A,E,H,M) then a space then the number of days (1-7): A: Animal Kingdom E: Epcot H: Hollywood Studios M: Magic Kingdom E 0
In JAVA please, I need help with just reading the inputted character and number at the same time. thanks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
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