Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Gavin Foyle
- * Assignment 1 Question 2
- * Version 1.0
- * 9-22-17
- */
- import java.util.Scanner;
- public class Question2 {
- public static void main(String[] args) {
- int year, day, month, date, j,k;
- System.out.println("Day of the week Calculator");
- System.out.println("__________________________");
- Scanner input1 = new Scanner(System.in);
- System.out.println("Please enter a year (numerically)");
- System.out.println();
- year = input1.nextInt();
- System.out.println("Please enter a month 1-12 (numerically)");
- month = input1.nextInt();
- System.out.println("Please enter a day 1-31 (numerically)");
- day = input1.nextInt();
- if (month <= 2) month += 12;
- String monthString = "";
- if (month==1) {month <= 31;
- if (month==2) month <= 28;
- if (date==3) month <= 31;
- if (month==4) month = <= 30;
- if (month==5) month <= 31;
- if (month==6) month <= 30;
- if (month==7) month <=31;
- if (month==8) month <= 31;
- if (month==9) month <= 30;
- if (month==10) month <= 31;
- if (month==11) month <= 30;
- if (month==12) month <= 31;
- k = year % 100;
- j = year / 100;
- date = ((day + (((month + 1) * 26) / 10) + k + (k / 4) + (j / 4)) + (5*j)) % 7 ;
- String str = "";
- if (date==0) str="Saturday";
- if (date==1) str="Sunday";
- if (date==2) str="Monday";
- if (date==3) str="Tuesday";
- if (date==4) str="Wednesday";
- if (date==5) str="Thursday";
- if (date==6) str="Friday";
- System.out.println("That date was a "+str+ ".");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement