Assignment title: Java


Question Java programming assignment Q Write a Java program called Ticket.java that prompts (asks) the user to enter a ticket number. The format of a valid ticket is CCCDD[C][C]

where D = a digit and C = a character and [C] means that the character at this position is optional.

The three characters at the start may be any characters (letters). If there is only one optional character at the end of the ticket String, then that character may only be 'S' or 'M'

If there are two optional characters at the end of the ticket String, then the characters can only be 'S' and 'M' in that order. So an example of a valid ticket could be:

ABC12M The user may enter a ticket String of any length. The valid length of a ticket is between 5 and 7 depending on the conditions above. Any ticket that is not in this length range is automatically invalid. A ticket that is invalid for any reason will result in a message being

displayed to the screen saying that the ticket is invalid, and no processing will be done with that ticket. This includes not showing any cost. Every effort should be made to give the exact reason why the ticket is invalid. For example,

wrong length, starts with an invalid character, or ends with an invalid character. These are

not the only reasons why a ticket is invalid, part of your task is to list all the conditions that make a ticket invalid and write code to cover those cases