Sunday, November 8, 2009

Guessing the Birth date.!

import javax.swing.JOptionPane;

public class GuessConfirmationDate{
public static void main(string[] args){

String set1=
"1 3 5 7\n"+
"9 11 13 15\n"+
"17 19 21 23\n"+
"25 27 30 31\n";

String set2=
"2 3 6 7\n"+
"10 11 14 15\n"+
"18 19 22 23"+
"26 27 30 31";

String set3=
"4 5 6 7\n"+
"12 13 14 15\n"+
"20 21 22 23\n"+
"28 29 30 31";

String set4=
"8 9 10 11\n"+
"12 13 14 15\n"+
"24 25 26 27\n"+
"28 29 30 31\n";

String set5=
"16 17 18 19\n"+
"20 21 22 23\n"+
"24 25 26 27\n"+
"28 29 30 31\n";

int date=0;

int answer=JOptionPane.showConfirmDialog(null,"Is ur birth date in these numbers?" +set1);

if(answer=JOptionPane.YES_OPTION)
date+=1;

int answer=JOptionPane.showConfirmDialog(null,"Is ur birth date in these numbers?" +set2);
if(answer=JOptionPane.YES_OPTION)
date+=2;

int answer=JOptionPane.showConfirmDialog(null,"Is ur birth date in these numbers?" +set3);
if(answer=JOptionPane.YES_OPTION)
date+=3;

int answer=JOptionPane.showConfirmDialog(null,"Is ur birth date in these numbers?" +set3);
if(answer=JOptionPane.YES_OPTION)
date+=4;

int answer=JOptionPane.showConfirmDialog(null,"Is ur birth date in these numbers?" +set4);
if(answer=JOptionPane.YES_OPTION)
date+=8;

nt answer=JOptionPane.showConfirmDialog(null,"Is ur birth date in these numbers?" +set5);
if(answer=JOptionPane.YES_OPTION)
date+=16;

JOptiopnPane.showMessageDialod(null,"Your birth date is"+ date +"!");
}
}
This is not my own program.But its a very good example of the GUI confirmation dialog box.However the logic is a bit complicated.