Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner dateInput = new Scanner(System.in);
- String date;
- System.out.print("What is the date? ");
- date = dateInput.next();
- String[] daysOfWeek = { "Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};
- String[] dayNumber = { "0", "1", "2", "3", "4", "5", "6"};
- int i = Integer.parseInt(date);
- if(Integer.parseInt(date) < 7) {
- i = Integer.parseInt(date);
- }
- else if (Integer.parseInt(date) >= 28 && Integer.parseInt(date) <= 31){
- i = i - 28;
- }
- else if (Integer.parseInt(date) >= 21 && Integer.parseInt(date) <= 27){
- i = i - 21;
- }
- else if (Integer.parseInt(date) >= 14 && Integer.parseInt(date) <= 20){
- i = i - 14;
- }
- else if (Integer.parseInt(date) >= 7 && Integer.parseInt(date) <= 13){
- i = i - 7;
- }
- else {
- System.out.println("Error with i");
- }
- int d = Integer.parseInt(dayNumber[i]);
- // Replies with date and day.
- if(Integer.parseInt(dayNumber[d]) <= 6 ) {
- System.out.println("The " + date + " is a " + daysOfWeek[d]);
- }
- else {
- System.out.println("Error with reply");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement