You are viewing a single comment's thread. Return to all comments →
/* One more way to solve this problem in java by using reasoning concept find day for given date. */
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
public static void main(String[] args) { Scanner in = new Scanner(System.in); String month = in.next(); String day = in.next(); String year = in.next(); int n_month = Integer.parseInt(month); int n_day = Integer.parseInt(day); int n_year = Integer.parseInt(year); int mon[] = {0,3,3,6,1,4,6,2,5,0,3,5}; int ye = 6; int total=0; if(n_year > 2000 && n_year < 3000) { int new_year = n_year % 2000; int new_year_rem = new_year /4; total = mon[n_month-1] + n_day + new_year + new_year_rem + ye; // System.out.print(mon[n_month-1] +" "+ n_day +" "+ new_year +" "+ new_year_rem +" "+ ye); } int ch = total % 7; switch(ch) { case 0: { System.out.print("SUNDAY"); break; } case 1: { System.out.print("MONDAY"); break; } case 2: { System.out.print("TUESDAY"); break; } case 3: { System.out.print("WEDNESDAY"); break; } case 4: { System.out.print("THURSDAY"); break; } case 5: { System.out.print("FRIDAY"); break; } case 6: { System.out.print("SATURDAY"); break; } } }
}
Seems like cookies are disabled on this browser, please enable them to open this website
Java Date and Time
You are viewing a single comment's thread. Return to all comments →
/* One more way to solve this problem in java by using reasoning concept find day for given date. */
import java.io.; import java.util.; import java.text.; import java.math.; import java.util.regex.*;
public class Solution {
}