If this is your first visit, be sure to
check out the FAQ by clicking the
link above. You may have to register
before you can post: click the register link above to proceed. To start viewing messages,
select the forum that you want to visit from the selection below.

Can someone tell me how to do this

how do i generate a random number
and then use this generated number to compare it with a number a user enters.

How can i use [y]es and [n]o . For example a user enter y and then in the
program I want to insert an if and else statement
how can i use if and else to guide the program to do certain things. Please
email me.

Re: Can someone tell me how to do this

If you don't know how to use "if" and "else" statements you should have
posted this in the java.getting.started newsgroup, or better still, find a
book that teaches you Java. There are lots. However...

if (boolean) {list of statements;}
else {list of statements;}

To generate a random number you use the static method "random" that's in the
class "Math" as follows:

double x = Math.random();

If you download the Java documentation from Sun's site it's not hard to find
this out... look in the index under "random" and there it is.

Edward <xocafox@aol.com> wrote in message news:38f7dfc1$1@news.devx.com...
>
> how do i generate a random number
> and then use this generated number to compare it with a number a user
enters.
>
> How can i use [y]es and [n]o . For example a user enter y and then in the
> program I want to insert an if and else statement
> how can i use if and else to guide the program to do certain things.
Please
> email me.