Page 551 - Cs_withBlue_J_C11_Flipbook
P. 551

13              s= sc.next();
                   14              System.out.print("Enter the Day of 1st January 2023 : ");

                   15              f= sc.next();
                   16          }

                   17
                   18          void find_day()

                   19          {
                   20              Scanner sc= new Scanner(System.in);
                   21              int mon[]={0,31,28,31,30,31,30,31,31,30,31,30,31};


                   22                  String day[]={"","SUNDAY","MONDAY","TUESDAY","WEDNESDAY","THURSDAY",
                                     "FRIDAY", "SATURDAY "};
                   23              int d,m,y,tot=30,v=0;

                   24              d=Integer.valueOf(s.substring(0,2));
                   25              m=Integer.valueOf(s.substring(3,5));

                   26              y=Integer.valueOf(s.substring(6));
                   27              for(int i=2;i<m;i++)

                   28                  tot=tot+mon[i];
                   29              tot=tot+d;

                   30              tot=tot+(365*(y-2023));
                   31              for(int i=2023;i<=y;i=i+4)

                   32                  tot++;
                   33              for(int i=0;i<=7;i++)

                   34              {
                   35                  if(f.equalsIgnoreCase(day[i]))

                   36                  {
                   37                      v=i;

                   38                      break;
                   39                  }
                   40              }

                   41              if(v==0||y<2023)

                   42              {
                   43                  System.out.println("Invalid Entry Parameter-EXITING...:");
                   44                  System.exit(0);

                   45              }
                   46              v=v+tot;




                                                                                                                       549
                                                                                                   Internal Assessment  549
   546   547   548   549   550   551   552   553   554   555   556