Created
August 12, 2020 19:15
-
-
Save muralidharan-rade/4035bf74b7a7e6ffcb66c326f97d3cfa to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.io.*; | |
import java.math.*; | |
import java.security.*; | |
import java.text.*; | |
import java.util.*; | |
import java.util.concurrent.*; | |
import java.util.regex.*; | |
class Result { | |
/* | |
* Complete the 'findDay' function below. | |
* | |
* The function is expected to return a STRING. | |
* The function accepts following parameters: | |
* 1. INTEGER month | |
* 2. INTEGER day | |
* 3. INTEGER year | |
*/ | |
public static String findDay(int month, int day, int year) { | |
Calendar cal = new GregorianCalendar(year, month-1, day); // month - 1 since month from 0 | |
System.out.print(year +":"+ month +":"+ day); | |
int weekDay = cal.get(Calendar.DAY_OF_WEEK); | |
String dayWeek = ""; | |
switch(weekDay) { | |
case 2: | |
dayWeek = "MONDAY"; | |
break; | |
case 3: | |
dayWeek = "TUESDAY"; | |
break; | |
case 4: | |
dayWeek = "WEDNESDAY"; | |
break; | |
case 5: | |
dayWeek = "THURSDAY"; | |
break; | |
case 6: | |
dayWeek = "FRIDAY"; | |
break; | |
case 7: | |
dayWeek = "SATURDAY"; | |
break; | |
case 1: | |
dayWeek = "SUNDAY"; | |
break; | |
} | |
return dayWeek; | |
} | |
} | |
public class UtilDayOfWeek { | |
public static void main(String[] args) throws IOException { | |
BufferedReader bufferedReader = new BufferedReader(new InputStreamReader(System.in)); | |
String[] firstMultipleInput = bufferedReader.readLine().replaceAll("\\s+$", "").split(" "); | |
int month = Integer.parseInt(firstMultipleInput[0]); | |
int day = Integer.parseInt(firstMultipleInput[1]); | |
int year = Integer.parseInt(firstMultipleInput[2]); | |
String res = Result.findDay(month, day, year); | |
System.out.println(res); | |
bufferedReader.close(); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment