+ 2
Please how can I assigned the random values generated between two numbers into an array and find the maximum and minimum value.
import java.util.*; class RandomNumbers { public static void main(String[] args) { int i,n; Random t = new Random(); double sum = 0; for (i = 1; i <= 10; i++) { n = t.nextInt (30); System.out.println (n); sum = sum + n; } double p = Math.sqrt(sum); double av = Math.max(n); System.out.println("the sum of Random numbers =" +av); System .out.println ("the square of sum =" +p); } }
16 Réponses
+ 3
thank you so much
+ 2
okay
+ 2
int max= 0;
int min= 0;
.......
for(i=1; i<=10; i++){
.......
if(i==1)
min= max= n;
else{
if(n<min) min= n;
if(n>max) max= n;
}
......
}
+ 2
hey KroW
+ 2
its not running with the code
+ 2
I'm supposed to find the max and min from the already generated numbers
+ 2
i still have another problem 😥😥
+ 2
Please help debug this code
https://code.sololearn.com/c9ZRybdxTbD9/?ref=app
+ 1
Morule Michaels ????
+ 1
Note that the dots (.....) represent your code int that context
+ 1
Morule Michaels Can you post the LINK of your code? Please dont copy here, post only his link url
+ 1
Morule Michaels This is not a chat... Dont write multiple reply... Write a message for reply. Anyway what is your problem?
+ 1
Morule Michaels Your have to not debug your code... You have to correct syntax and logic errors... Read the console for get errors location and info