Cần giúp đỡ bài tập Java.

Arisato Minato

Sith Lord Revan
Lão Làng GVN
Đề bài là thế này

Write a Java program that generates and displays 100 random integers in the range of[10, 25] inclusively. The program then displays the number of occurrences for each number in that range. Next, the program displays the maximum, minimum and average (with exactly 2 digits after the decimal) value of the occurrences. Finally the program asks if the user want to run it again to act accordingly. Note that user must answers “y” for yes and “n” for no. In the case user enters other values, the program lets the user to re-enter again until “y” or “n” is correctly entered.

ví dụ mẫu :

Mã:
*************************************************
Display 100 random integers in [10, 25]
14 14 18 24 12 25 16 12 18 16
15 16 16 15 17 19 10 21 14 25
21 24 10 19 25 17 19 13 25 24
23 25 15 25 18 23 18 14 24 11
21 12 20 24 14 18 11 12 14 13
14 20 11 16 21 15 15 17 20 24
10 18 20 18 24 23 17 18 15 11
20 19 14 23 20 23 18 22 20 11
10 24 22 12 10 11 11 12 12 13
14 12 15 15 13 24 23 23 11 23
*************************************************
Display occurrences
10: 5
11: 8
12: 8
13: 4
14: 9
15: 8
16: 5
17: 4
18: 9
19: 4
20: 7
21: 4
22: 2
23: 8
24: 9
25: 6
Max occurrences: 9
Min occurrences: 2
Average occurrences: 6.25
*************************************************
Run again (y/n)? abc
Invalid. Please enter "y" or "n":

Mình làm được đến bước tạo ra một dãy số gồm 100 số ngẫu nhiên là tịt ngòi. Các bạn giúp mình phần tiếp theo với.
 
Back
Top