import javax.swing.JOptionPane;
public class RandomIntegers {
public static void main(String args[]) {
int value;
String output = "";
// loop 20 times
for (int counter = 1; counter <= 20; counter++) {
// pick random integer between 1 and 6
value = 1 + (int) (Math.random() * 6);
output += value + " "; // append value to output
// if counter divisible by 5, append newline to String output
if (counter % 5 == 0)
output += "\n";
}
JOptionPane.showMessageDialog(null, output, "20 Random Numbers from 1 to 6",JOptionPane.INFORMATION_MESSAGE);
System.exit(0);
}
}
что я хочу сделать, это получить сумму. Например: 5 4 3 2 1 = 15 просто так.Как добавить эти случайные целые числа?
Как добавить номера? num1 + num2. – csmckelvey