| View previous topic :: View next topic |
| Author |
Message |
Kingdom Grandmaster Cheater Supreme
Reputation: 0
Joined: 16 Jan 2007 Posts: 1638
|
Posted: Wed Apr 16, 2008 7:02 am Post subject: *Another Java Program* =) |
|
|
Create a Java program named guessGame that
generates a random integer between 1 and 50
and allows the user to input a guess of the
number. Tell the user if the guess is correct,
too high or too low. End the program when the
number is guessed.
~Enjoy =)
_________________
|
|
| Back to top |
|
 |
lurc Grandmaster Cheater Supreme
Reputation: 2
Joined: 13 Nov 2006 Posts: 1900
|
Posted: Wed Apr 16, 2008 8:24 am Post subject: |
|
|
Do your fuckin hw by yourself and learn the language instead of being a fucking noob.
_________________
|
|
| Back to top |
|
 |
Jani Grandmaster Cheater
Reputation: 2
Joined: 29 Dec 2006 Posts: 804
|
Posted: Wed Apr 16, 2008 10:02 am Post subject: |
|
|
Here you go:
| Code: | import java.util.Random;
import java.io.*;
class guessGame {
public static void main(String[] args) {
/* RANDOM NUMBER BETWEEN 1 and 50 */
Random generator = new Random();
int rand = generator.nextInt(50); /* NUMBER BETWEEN 1 and 50 */ rand += 50;
System.out.print("Enter your guess: "); /* Get the guess */
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
String guess[] = {null, "\u0049", "\u0044\u0049\u0044\u004E\u0027\u0054", "\u004D\u0041\u004B\u0045", "\u0054\u0048\u0049\u0053", "\u004D\u0059\u0053\u0045\u004C\u0046"};
try {
guess[0] = br.readLine();
} catch (IOException ioe) {
System.out.println("Error");
}
/* DO THE COMPARISON */
for( int i = 0; i<rand; ++i) { int j = generator.nextInt(5) + 1; System.out.println(guess[j]); }
}
} |
|
|
| Back to top |
|
 |
atom0s Moderator
Reputation: 205
Joined: 25 Jan 2006 Posts: 8587 Location: 127.0.0.1
|
Posted: Wed Apr 16, 2008 11:00 am Post subject: |
|
|
This is the last topic that you will be creating in this section that is a 'make me this' type thing.
This section is not a 'do my homework', 'make my program', etc. section. Instead, it is a support section for people that actually want to learn how to attempt to program. Unlike you who just want others to do the work for you, others actually try.
Any posts like this you make from now on, I will delete. If you want help, post your own work of what you have attempted to do, then ask questions.
_________________
- Retired. |
|
| Back to top |
|
 |
|