This program is supposed to request you to enter a number... Then requires you to confirm the same number but only this time without the last digit.
Like for example: You enter number, e.g. 1234567... then it asks you to verify the number (but this time you only enter the first 6 digits of the same number) e.g. 123456.
Then it will take the last digit of the first entry and put it together with at the end of the second entry so it can give you the full 7 digit number, i.e. 1234567.
If the numbers match it will tell you the ticket is valid.. if not it will tell you the ticket is invalid:
import javax.swing.JOptionPane; import javax.swing.JFrame; public class Validation { public static void main(String[] args) throws Exception { //Declaration of strings String inputOne; String inputTwo; //Declaration of long numbers int ticket; int confirm; //Declaration of integers inputOne=JOptionPane.showInputDialog("Please enter the ticket number: "); inputTwo=JOptionPane.showInputDialog("Please confirm the ticket number: "); ticket=Integer.parseInt(inputOne); confirm=Integer.parseInt(inputTwo); int remainder = ticket%10; if ((confirm + remainder)==ticket) { JOptionPane.showMessageDialog(null, "The ticket number you just entered is valid", "Ticket Validator", JOptionPane.INFORMATION_MESSAGE); } else { JOptionPane.showMessageDialog(null, "The ticket number you just entered is invalid", "Ticket Validator", JOptionPane.INFORMATION_MESSAGE); } { System.exit(0); } } }