Guess my Birthday?

import java.util.Scanner;
import javax.swing.JOptionPane;

class Birthday {
    public static void main(String[] args) {
        int birthDay = 0;
       
        Scanner input = new Scanner(System.in);
       
        // Table 1
        int answer = JOptionPane.showConfirmDialog(null, "1  3  5  7\n9 11 13 15\n17 19 21 23\n25 27 29 31");
        if (answer == 0)
            birthDay += 1;
       
        // Table 2
        answer = JOptionPane.showConfirmDialog(null, "2 3 6 7\n10 11 14 15\n18 19 22 23\n26 27 30 31");
        if (answer == 0)
            birthDay += 2;
        // Table 3   
        answer = JOptionPane.showConfirmDialog(null, "4 6 6 7\n12 13 14 15\n20 21 22 23\n28 29 30 31");
        if (answer == 0)
            birthDay += 4;   
        // Table 4   
        answer = JOptionPane.showConfirmDialog(null, "8 9 10 11\n12 13 14 15\n24 25 26 27\n28 29 30 31");
        if (answer == 0)
            birthDay += 8;       
        // Table 5   
        answer = JOptionPane.showConfirmDialog(null, "16 17 18 19\n20 21 22 23\n24 25 26 27\n28 29 30 31");
        if (answer == 0)
            birthDay += 16;       
           
        JOptionPane.showMessageDialog(null, "So your birthday is " + birthDay);   
    }
}

Comments

Popular posts from this blog

Zeller's Congruence

Property Event-Delegation

Method with variable arguments