|
Re: Write a loop that prompts user for a year
|
Posted: Jun 19, 2003 2:08 AM
|
|
> Write a loop that prompts the user for a year, whichis an > integer between 1995 abd 2003 (inclusive).import java.util.GregorianCalendar;
import java.util.Date;
public class Homework
{
public static void main(String[] args)
{
GregorianCalendar now = new GregorianCalendar();
GregorianCalendar end = new GregorianCalendar();
end.set(GregorianCalendar.YEAR, end.get(GregorianCalendar.YEAR) + 1);
// Prompt the user for a year...
while(now.before(end))
{
System.out.println("Enter an integer between 1995 and 2003 (inclusive).");
now.setTime(new Date());
}
}
}
Vince.
(Sorry.)
|
|