cancel
Showing results for 
Search instead for 
Did you mean: 

Number Generator

Former Member
0 Kudos

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.

Accepted Solutions (0)

Answers (1)

Answers (1)

Former Member
0 Kudos

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