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 );
}
}
what i want to do is to get the sum .for example : 5 4 3 2 1 = 15 just like this.