Question: Hints TimeTravel class 1. The ticket code should be read in all at once and stored in a variable of type String, after which the
TimeTravel.java Requirements: The purpose of this program is to accept coded ticket information to another time and place (and back) as input that includes the date, time, category, price, and seat, followed by the description of the travel. Note that the nine digits for price have an implied decimal point. The program should then print the ticket information including the actual cost, which is the price with discount applied as appropriate: 50% for a student ticket (s), 25% for employee ticket(e), and none for regular tickets (i.e., anything other than s or e). The last line of the ticket should contain a "prize number" between I and 9999 inclusive that should always be printed as 4 digits (e.g., 7 should be printed as 0007). The coded input is formatted as follows: 153012152090s02498990018BTime Machine 7 to NYC 12/31/1880 time date ticket description (goes through last character in the code) category scat category [s, e, any other character is a regular ticket with no discount; store this as type char] "price [012479900 has an implied decimal point; the double value should be 124799.00] Whitespace (e.g., spaces or tabs) before or after the coded information should be disregarded. Hint: After the ticket code has been read in as a String, it should be trimmed using the trimO method.] Your program will need to print the date and time, seat, the itinerary (i.e, ticket description), the ticket price, the ticket category, the actual cost, and a random prize number in the range to 9999. If the user enters a code that does not have at least 26 characters, then an error message should be printed and the program should end. [The 26 character of the code is part of the ticket description.] Design: Several examples of input/output for the program are shown below Line # Enter ticket code: 123456789 Invalid ticket code Ticket code must have at least 26 characters Note that the ticket code below results in the indicated output except for the prize number which is random. When more than one item is shown on the same line (e.g., time, date, and seat on line 3), there are three spaces between them (do not use the tab escape sequence lt) Line # 1 Pro Enter ticket code: 153012152090s02498990018BTime Machine 7 to NYC 12/31/1880 Time: 15:30 Date: 12/15/2090 Seat: 18B Itinerary: Time Machine 7 to NYC 12/31/1880 Price: $249,899.00 Cost: $124,949.50 Category: s Prize Number: 9019
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
