on 10-19-2006 8:13 AM
I have been working on this random number generator for a 4th grade class and I can't quite get the second part correct I have this so far:
import java.util.*;
public class gen {
public static void main (String[] args) {
int count, rval;
Random rgen;
rgen = new Random();
for (count = 0; count < 1; ++count) {
rval = rgen.nextInt(101);
System.out.printf(" %d", rval);
}
System.out.println();
}
}
I need the program to answer if your guess is correct. For instance if the number was 62 I would like this to be the result:
Enter your guess: 71
71 is too high.
Enter your quess: 14
14 is too low.
Enter your guess: 23
23 is too low.
Enter your guess: 65
65 is too high.
Enter your quess: 37
37 is too low.
Enter your guess: 44
44 is too low.
Enter your guess: 62
62 is correct. You needed 7 guesses.
Hi,
you are not asking seriously in this IT-professional forum for a solution of a very basic Java homework ?
If you can't find the answer by doing a bit of Google research you might redecide if you have selected the correct study course.
Best Regards, Astrid
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
9 | |
9 | |
6 | |
6 | |
6 | |
5 | |
3 | |
3 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.