The Artima Developer Community
Sponsored Link

Java Answers Forum
Write a loop that prompts user for a year

2 replies on 1 page. Most recent reply: Jun 19, 2003 2:08 AM by Vincent O'Sullivan

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 2 replies on 1 page
janeceg

Posts: 2
Nickname: jgg
Registered: Jun, 2003

Write a loop that prompts user for a year Posted: Jun 10, 2003 6:57 AM
Reply to this message Reply
Advertisement
Write a loop that prompts the user for a year, whichis an integer between 1995 abd 2003 (inclusive).


E. Nielsen

Posts: 9
Nickname: en
Registered: Feb, 2003

Re: Write a loop that prompts user for a year Posted: Jun 16, 2003 3:53 PM
Reply to this message Reply
Okie Duke!

.-)

Vincent O'Sullivan

Posts: 724
Nickname: vincent
Registered: Nov, 2002

Re: Write a loop that prompts user for a year Posted: Jun 19, 2003 2:08 AM
Reply to this message Reply
> 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.)

Flat View: This topic has 2 replies on 1 page
Topic: Trouble with recognised custom event handler class? Previous Topic   Next Topic Topic: How to activate LDAP server for access ADSI using JNDI

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use