Explore BrainMass
Share

# Ticket Number Validator

Write a Java application that indicates invalid ticket number entries. It prompts a ticket agent to enter a six-digit ticket number. Ticket numbers are designed so that if you drop the last digit of the number, then divide the number by 7, the remainder of the division will be identical to the last dropped digit.

#### Solution Preview

Please rename attached 438995-Ticket.java to Ticket.java before compiling and running it.

Few sample sessions with the program are pasted below.

> java Ticket
Enter a 6-digit positive ticket number : 999924
Ticket number is VALID.

> java Ticket
Enter a 6-digit positive ticket number : 9999992
Ticket number not a 6-digit positive number!

> java Ticket
Enter a 6-digit positive ticket number : 99999
Ticket number not a 6-digit positive number!

> java Ticket
Enter a 6-digit positive ticket number : -999924
Ticket number not a 6-digit positive ...

#### Solution Summary

Well commented, easy to understand implementation, that also handles negative number input. Few sample sessions are also provided that test different aspects of the logic.

\$2.19