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.