I am trying to implement part of a program that will convert a DD/MM/YY input into a DD/MM/YYYY input. I have used an if statement to ask the program to check whether the input number is <13, and if so, to add 2000 to the input number - giving a result of 2012 if 12 is input. If the number is >13 and <100, I have asked the program to add 1900.
I am very new to java and am experiencing two compiler errors which I have been unable to overcome so far (down from 36, haha). The compiler error is "not a statement". Both refer to the line with the else statement. The code is as follows (obviously still a WIP and not a completed program yet) -
import java.util.*;
public class FindDay4Birthdate
{
public static void main(String[] args)
{
String dayInput = "";
String monthInput = "";
String yearInput = "";
int bday;
int bmonth;
int byear;
String daysList[] = {
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
};
String monthList[] = {
"January", "Feburary", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
};
Scanner sc = new Scanner(System. in );
sc.useDelimiter("[-/.\\s]");
System.out.print("Please enter your date of birth (dd/mm/yyyy) - ");
if (sc.hasNext())
{
dayInput = sc.next();
monthInput = sc.next();
yearInput = sc.next();
bday = Integer.parseInt(dayInput);
bmonth = Integer.parseInt(monthInput);
byear = Integer.parseInt(yearInput);
} // end if statement
if (byear = (byear > 0));
{
if (byear = (byear < 13))
{
byear = (byear + 2000);
}
else(byear = (byear > 13 && byear < 100));
{
byear = (byear + 1900);
}
} // end if statement
bmonth -= 1; //set month to correct array
String day = daysList[bday];
String month = monthList[bmonth];
int yearCount = (byear - 1901);
int daysInYear = 365;
int dayCount = (daysInYear * yearCount);
System.out.println("You were born on " + day + " " + bday + " " + month + " " + byear);
System.out.println(yearCount + " " + daysInYear + " " + dayCount); // test output only
/* Todo
*
*TASK 2 -
*Implement daysPerMonth - Feb set to 28 days
*Use count to determine correct day for birthdate
*
*TASK 3 -
*User input needs to allow char based months and 2 digit years need to be converted to 4 digit years
*Implement leap years */
}
}
byear=(byear >0)are you sure you know whats happening here?true, thenbyear < 13makes no sense..