The output should be displayed in uppercase letters.
Suppose the following INPUT sequence is given to the program:
1999-5
1998-6
Then the output should be:
MONDAY
TUESDAY
Solution:
import java.text.DateFormatSymbols;
import java.util.Calendar;
import java.util.Scanner;
public class Solution {
/**
* @param args
*/
public static void main(String[] args) {
boolean condition = false;
do {
Scanner scanner = new Scanner(System.in);
String value = scanner.nextLine();
condition = value.equalsIgnoreCase("exit");
if(!condition && value.contains("-")){
calculate(value);
}
System.out.println("Count is: " + condition);
} while (!condition);
}
private static void calculate(String value) {
final String[] input = value.split("-");
Calendar cl = Calendar.getInstance();
cl.set(Integer.parseInt(input[0]), Integer.parseInt(input[1]), 28);
String[] weekdays = new DateFormatSymbols().getWeekdays();
System.out.println(weekdays[cl.get(Calendar.DAY_OF_WEEK)].toUpperCase());
}
}
No comments:
Post a Comment