Advertisement
saykotislam

1

Feb 24th, 2021
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.96 KB | None | 0 0
  1. package harpic;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class Harpic {
  6.     public static void main(String[] args) {
  7.         Scanner input=new Scanner(System.in);
  8.        
  9.         int A=0,B,C,D;
  10.         String month,again;
  11.        
  12.         for(int j=0;;j++){
  13.        for (int i = 0;; i++) {
  14.             System.out.print("Please enter the month: ");
  15.             month= input.nextLine();
  16.            
  17.             System.out.print("Please enter the day of the month: ");
  18.             B=input.nextInt();
  19.            
  20.             System.out.print("Please enter the year: ");
  21.             C=input.nextInt();
  22.             if("March".equals(month) && B<=31){
  23.                  A=3;
  24.                        
  25.                         break;
  26.             }
  27.             else if("April".equals(month) && B<=30){
  28.                  A=4;
  29.                        
  30.                         break;
  31.             }
  32.             else if("May".equals(month) && B<=31){
  33.                  A=5;
  34.                        
  35.                         break;
  36.             }
  37.             else if("June".equals(month) && B<=30){
  38.                  A=6;
  39.                        
  40.                         break;
  41.             }
  42.             else if("July".equals(month) && B<=31){
  43.                  A=7;
  44.                        
  45.                         break;
  46.             }
  47.             else if("August".equals(month) && B<=31){
  48.                  A=8;
  49.                        
  50.                         break;
  51.             }
  52.             else if("September".equals(month) && B<=30){
  53.                  A=9;
  54.                        
  55.                         break;
  56.             }
  57.             else if("October".equals(month) && B<=31){
  58.                  A=10;
  59.                         System.out.println("A = "+A);
  60.                         break;
  61.             }
  62.             else if("November".equals(month) && B<=30){
  63.                  A=11;
  64.                        
  65.                         break;
  66.             }
  67.             else if("December".equals(month) && B<=31){
  68.                  A=12;
  69.                        
  70.                         break;
  71.             }
  72.             else if("January".equals(month) && B<=31){
  73.                  A=13;
  74.                  C=C-1;
  75.                        
  76.                        
  77.                         break;
  78.             }
  79.             else if("February".equals(month) && B<=29){
  80.                  A=14;
  81.                  C=C-1;
  82.                        
  83.                         break;
  84.             }
  85.             else {
  86.                 System.out.println("try again!");
  87.                 continue;  
  88.             }
  89.              
  90.         }
  91.         int temp,year1,year2;
  92.         temp=C;
  93.         year1=temp%100;
  94.         year2=temp/100;
  95.         C=year1;
  96.         D=year2;
  97.         int ans;
  98.         ans=(((13*(A+1)/5))+(C/4)+(D/4)+B+C+(5*D))%7;
  99.        
  100.         if(ans==0){
  101.             System.out.println(month+" "+B+", "+temp+" is a Saturday");
  102.         }
  103.         if(ans==1){
  104.             System.out.println(month+" "+B+", "+temp+" is a Sunday");
  105.         }
  106.         if(ans==2){
  107.             System.out.println(month+" "+B+", "+temp+" is a Monday");
  108.         }
  109.        
  110.         if(ans==3){
  111.             System.out.println(month+" "+B+", "+temp+" is a Tuesday");
  112.         }
  113.         if(ans==4){
  114.             System.out.println(month+" "+B+", "+temp+" is a Wednesday");
  115.         }
  116.         if(ans==5){
  117.             System.out.println(month+" "+B+", "+temp+" is a Thursday");
  118.         }
  119.         if(ans==6){
  120.             System.out.println(month+" "+B+", "+temp+" is a Friday");
  121.         }
  122.        
  123.        // Scanner input=new Scanner(System.in);
  124.         System.out.print("Would you like to convert another date? ");
  125.        
  126.         char c = input.next().charAt(0);
  127.         if("y".equals(c)){
  128.             continue;
  129.         }
  130.         if("n".equals(c)){
  131.             System.out.print("Program terminated normally.");
  132.             break;
  133.         }
  134.        
  135.        
  136.        
  137.         }
  138.      
  139.     }
  140.    
  141. }
  142.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement