Setting a fixed date and counting the number of days to an input birthdate
to determing day of week - Java
My task is such - I need to set a specific date - 01/01/1913, which is a
wednesday. I then need the user to input their birthdate. The program will
then calculate which day of the week the person was born in. We are not
allowed to use the gregorian calendar to do it for us, we are required to
input the algorithm ourselves.
So far, I have the input set up,
public class FindDay4Birthdate {
public static void main(String[] args) {
// declare variables
String bbday = "";
String bbmonth = "";
String bbyear = "";
int bday;
int bmonth;
int byear;
String daysList[] = {"Sunday", "Monday", "Tuesday", "Wednesday",
"Thursday", "Friday", "Saturday"};
Scanner sc = new Scanner(System.in);
System.out.print("Please enter your date of birth - ");
sc.useDelimiter("[-/.\\s]");
if (sc.hasNext()); {
bbday = sc.next();
bbmonth = sc.next();
bbyear=sc.next();
bday = Integer.parseInt(bbday);
bmonth = Integer.parseInt(bbmonth);
byear = Integer.parseInt(bbyear);
} // end if statement
I am not sure where to go from here. Any help on how to take the next step
would be appreciated. I know that I need to use mod 7, but do not know
how, or where, I should use it.
No comments:
Post a Comment