Female in dire straights.. Please help ?

Hi all,
I am finding it impossible to write a shortpiece of Java that will allow me to create a guessing game. I want to write a guessing game whereby the computer generates a random number between 1 and 1000. The player must guess the number, with the program responding with either "too high" or "Too low" or "Well Done". When the player has eventually guessed correctly, the program will show how many attempts were required. If someone can help me within the next 10 hours, then they have literally saved my life !

Thanks in advance...
Sarah
email:simply@tesco.net
[589 byte] By [developer-network] at [2007-11-15 19:10:36]
# 1 Re: Female in dire straights.. Please help ?
U can try this code. It is console thing, if u want GUI for it u can modify it urself or tell me (by replying to this post, and tell me if u want appln/applet in that case).

import java.io.*;

public class GuessGame
{
public static void main( String arg[] )
{
int iNumber = (int)(1 + (Math.random() * 1000));
int iEntered = 0;
int iAttempts = 0;
DataInputStream inp = new DataInputStream( System.in );

do
{
System.out.print( "\nGive a try: " );
try
{
iEntered = Integer.parseInt( inp.readLine() );
if( iEntered > iNumber )
System.out.println( "Too high." );
else if( iEntered < iNumber )
System.out.println( "Too low." );
}
catch( Exception e )
{ System.out.println( "Hey, don't get frustrated, u can do it!" ); }
}
while( iEntered != iNumber );
System.out.println( "Well done." );
}
}

This code should work for JDK1.0 and above.

- UnicMan
http://members.tripod.com/unicman
unicman at 2007-11-10 3:02:00 >
# 2 Re: Female in dire straights.. Please help ?
Thank you so much... consider my life saved.
Thanks,
Sarah
at 2007-11-10 3:03:04 >
# 3 Re: Female in dire straights.. Please help ?
Why "Female in dire straights"? Who cares what your gender is?
cloder at 2007-11-10 3:04:02 >
# 4 Re: Female in dire straights.. Please help ?
I must say that I found the subject of your post very interesting ....

FEMALE in dire straights .....

How far will you go ??
longjohnsilver at 2007-11-10 3:05:00 >
# 5 Re: Female in dire straights.. Please help ?
Wow! how did you get into a position where your life literally depends on coding a guessing game?

Are you programming for Hizbollah, or Saddam Hussein? The Mafia?

I'm impressed ;-)

To email me remove '_spamjam' from my email address
dlorde at 2007-11-10 3:06:10 >