Wednesday, 5 September 2012

How to Guess Birthday using Java Program

| |

Run this program and find your Birthday in given table . If it is there push "YES" button , Otherwise "NO" and continue so on..... in the end, it will give your birthday.

import javax.swing.JOptionPane;


public class Birthday
{
 public static void main(String arg[])
 {
   String s1="1 3 5 7\n"+"9 11 13 15\n"+"17 19 21 23\n"+"25 27 29 31\n";
  
   String s2="2 3 6 7\n" + "10 11 14 15\n" + "18 19 22 23\n" + "26 27 30 31\n";
 
   String s3="4 5 6 7\n" + "12 13 14 15\n" + "20 21 22 23\n" + "28 29 30 21\n";
 
  String s4="8 9 10 11\n" + "12 13 14 15\n" + "24 25 26 27\n" + "28 29 30 31\n";
 
  String s5="16 17 18 19\n " + "20 21 22 23\n" + "24 25 26 27\n" + "28 29 30 31\n";

  int date=0;
  int ans=JOptionPane.showConfirmDialog(null,"1st Table \n \n IS your BIRTHDAY in these number? \n\n" + s1);
  if(ans==JOptionPane.YES_OPTION)
	date+=1;

  int ans1=JOptionPane.showConfirmDialog(null,"2nd Table \n\n IS your BIRTHDAY in these number? \n\n"+s2);
  if(ans1==JOptionPane.YES_OPTION)
	date+=2;
  
  int ans2=JOptionPane.showConfirmDialog(null,"3rd Table \n\n IS your BIRTHDAY in these number?\n\n"+s3);
  if(ans2==JOptionPane.YES_OPTION)
   date+=4;

  int ans3=JOptionPane.showConfirmDialog(null,"4th Table \n\n IS your BIRTHDAY in these number?\n\n"+s4);
  if(ans3==JOptionPane.YES_OPTION)
   date+=8;

  int ans4=JOptionPane.showConfirmDialog(null,"5th Table \n\n IS your BIRTHDAY in these number ?\n\n"+s5);
  if(ans4==JOptionPane.YES_OPTION)
   date+=16;
  
  JOptionPane.showMessageDialog(null,"Your Birthday is "+date +"!");
  
  JOptionPane.showMessageDialog(null,"Thank You\n\nIs prepared By Nikul Chaudhary ");
 }
}
You also download a this program.
      DOWNLOAD 






Ebay Ads:
Electronics, Cars, Fashion and More Online Shopping  
www.ebay.com | www.ebay.co.uk | ebay.de

Related Post :

0 comments:

Post a Comment

Powered by Blogger.