+ 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); } }

19th Jun 2018, 11:34 AM
Morule Michaels
Morule Michaels - avatar
15 Antworten
+ 3
thank you so much
19th Jun 2018, 1:55 PM
Morule Michaels
Morule Michaels - avatar
+ 2
okay
19th Jun 2018, 11:59 AM
Morule Michaels
Morule Michaels - avatar
+ 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; } ...... }
19th Jun 2018, 1:18 PM
KrOW
KrOW - avatar
+ 2
hey KroW
19th Jun 2018, 1:20 PM
Morule Michaels
Morule Michaels - avatar
+ 2
its not running with the code
19th Jun 2018, 1:42 PM
Morule Michaels
Morule Michaels - avatar
+ 2
I'm supposed to find the max and min from the already generated numbers
19th Jun 2018, 1:43 PM
Morule Michaels
Morule Michaels - avatar
19th Jun 2018, 1:45 PM
Morule Michaels
Morule Michaels - avatar
+ 2
i still have another problem 😥😥
19th Jun 2018, 1:56 PM
Morule Michaels
Morule Michaels - avatar
19th Jun 2018, 2:01 PM
Morule Michaels
Morule Michaels - avatar
19th Jun 2018, 1:21 PM
KrOW
KrOW - avatar
+ 1
Note that the dots (.....) represent your code int that context
19th Jun 2018, 1:43 PM
KrOW
KrOW - avatar
+ 1
Morule Michaels Can you post the LINK of your code? Please dont copy here, post only his link url
19th Jun 2018, 1:44 PM
KrOW
KrOW - avatar
+ 1
Morule Michaels This is not a chat... Dont write multiple reply... Write a message for reply. Anyway what is your problem?
19th Jun 2018, 1:58 PM
KrOW
KrOW - avatar
+ 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
19th Jun 2018, 2:09 PM
KrOW
KrOW - avatar