-
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
Forum Rules
|
Top DevX Stories
Easy Web Services with SQL Server 2005 HTTP Endpoints
JavaOne 2005: Java Platform Roadmap Focuses on Ease of Development, Sun Focuses on the "Free" in F.O.S.S.
Wed Yourself to UML with the Power of Associations
Microsoft to Add AJAX Capabilities to ASP.NET
IBM's Cloudscape Versus MySQL
|
Bookmarks