Welcome

i make the www fun

MY PROGRAMS

Number  Converter   V2.0 

Number  Converter   V1.0 

Day Of The Week

import javax.swing.JOptionPane;

class day {
        public static void main(String[] args)throws Exception {
          try {        
                String in = JOptionPane.showInputDialog("Enter date in following format (DD/MM/YYYY)"); 
                
                int temp1, temp2;

                temp1 = in.indexOf('/');          //FINDING

                temp2 = in.lastIndexOf('/');      //SLASHES

                String date = in.substring(0,temp1);       

                String month = in.substring((temp1+1),temp2);

                String year = in.substring(temp2+1);


                //--------------------------------------------


                int d = Integer.parseInt(date);

                int m = Integer.parseInt(month);

                int y = Integer.parseInt(year);



                //============================================
                //  CHANGING MONTHS ACCORDING TO ZELLER'S RULE
                //============================================

                if(m==1) {
                        y = y-1;
                        m = 11;
                }
                else  if(m==2) {
                        y = y-1;
                        m = 12;
                }
                else m = m-2;


                int y1 = Integer.parseInt(Integer.toString(y).substring(0,2));

                int y2 = Integer.parseInt(Integer.toString(y).substring(2));


                



                //============================================
                //              FINAL CALCULATION
                //============================================

                int day = d + (((13*m)-1)/5)+ y2 + (y2/4) + (y1/4) + (5*y1);






                //============================================
                //             CONVERTING INTO DAY
                //============================================

                day = day%7;




                String week="";

                if(day==0 || day==7) week = "SUNDAY";

                else if(day==1) week = "MONDAY";

                else if(day==2) week = "TUESDAY";

                else if(day==3) week = "WEDNESDAY";

                else if(day==4) week = "THURSDAY";

                else if(day==5) week = "FRIDAY";

                else if(day==6) week = "SATURDAY";


            

                //============================================
                //              FINAL PRINTING
                //============================================

                JOptionPane.showMessageDialog(null,"The  Day  On  " + in + "  Was\\Will  Be  :  " + week); 
                
           }

           catch(StringIndexOutOfBoundsException e) {
                JOptionPane.showMessageDialog(null,"ERROR : You Entered Date In Wrong Format");
           }

           catch(NullPointerException e) {
                JOptionPane.showMessageDialog(null,"You Quitted From The Program");
           }

           catch(Exception e) {
                JOptionPane.showMessageDialog(null, "SORRY ! SOME ERROR OCCURED");
           }

           finally {
                JOptionPane.showMessageDialog(null,"Thanks For Using My Program\n-Program By Kishlaya");
           }

        }
}