Hi all, i have to make an application that can take the user's input and finds out if the year is a leap year. The input has to be divisible by 4 and 400 but not by 100. This would then produce an answer if the user's input is true (the input is a leap year) or false (the input is not a leap year).
right it sounds easy (and probably is for you guys!) but there one small thing i would like to ask. In my program i have a class called "Year" and an application called "YearApp". In my program "Year" i have the code to prompt the user to enter the year. In my application "YearApp" how do i call that code so it can be act apon?
my codes are as follows:
program "Year.java"
// An application that can take the user's input and finds out if the year is a
// leap year. The input has to be divisible by 4 and 400 but not by 100. This
// would then produce an answer if the user's input is true (the input is a leap// year) or false (the input is not a leap year).
//11/11/08
import java.io.*;
public class Year {
public static void main (String[] args) throws IOException{
int uInput;
// Create BufferedReader instance to enable input from keyboard
InputStreamReader input = new InputStreamReader(System.in);
BufferedReader keyboardInput = new BufferedReader(input);
System.out.println("please enter the year and I will find out if it's a leap year");
uInput = new Integer(keyboardInput.readLine()).intValue();
isLeapYear(uInput);
}
public static final int getYear(int u ){
int uInput = u;
return u;
}
public static final boolean isLeapYear(int getYear){
boolean aLeapYear;
if (getYear%4 == 0)
if (getYear%100 != 0)
if (getYear%400 != 0)
aLeapYear = true;
else aLeapYear = false;
else aLeapYear = false;
else aLeapYear = false;
return aLeapYear;
}
}
my application "YearApp":
// An application that can take the user's input and finds out if the year is a
// leap year. The input has to be divisible by 4 and 400 but not by 100. This
// would then produce an answer if the user's input is true (the input is a leap// year) or false (the input is not a leap year).
//11/11/08
public class YearApp {
public static void main(String[] args){
Year LeapYear = new Year();
System.out.println(LeapYear.isLeapYear);
}
}
i haven't quite finish YearApp yet, that why im wondoring how to prompt the user for the input.
EDIT: To fix this issue do i have to prompt the user in my "YearApp" and implement everything that way?
Thanks