import javax.swing.JOptionPane;
import javax.swing.JTextArea;
public class random {
public static void main(String[] args) {
int value;
int sum = 0;
JTextArea number = new JTextArea();
for (int counter = 1; counter <= 16; counter++) // loop 16 times
{
value = (int) (Math.random() * 9); // pick random integer between 0 and 9
number.append(value + " "); // append value
sum += value; // count sum
if (counter % 4 == 0) // if counter divisible by 4, append newline
{
number.append("= " + sum);
number.append("\n");
sum = 0; // reset line_sum
}
}
JOptionPane.showMessageDialog(null, number);
System.exit(0);
}
}
pahelp nmn po ako .as of now po kasi ang output ng code ko is ganito :
4 0 0 4 = 8
3 6 3 6 = 18
1 1 5 1 = 8
1 0 5 1 = 7
gusto ko po sana na iadd cla pababa .parang ganito po :
4 0 0 4
3 6 3 6
1 1 5 1
1 0 5 1
9 7 13 12 -> ito po sagot nila pag i-nad pababa
import javax.swing.JTextArea;
public class random {
public static void main(String[] args) {
int value;
int sum = 0;
JTextArea number = new JTextArea();
for (int counter = 1; counter <= 16; counter++) // loop 16 times
{
value = (int) (Math.random() * 9); // pick random integer between 0 and 9
number.append(value + " "); // append value
sum += value; // count sum
if (counter % 4 == 0) // if counter divisible by 4, append newline
{
number.append("= " + sum);
number.append("\n");
sum = 0; // reset line_sum
}
}
JOptionPane.showMessageDialog(null, number);
System.exit(0);
}
}
pahelp nmn po ako .as of now po kasi ang output ng code ko is ganito :
4 0 0 4 = 8
3 6 3 6 = 18
1 1 5 1 = 8
1 0 5 1 = 7
gusto ko po sana na iadd cla pababa .parang ganito po :
4 0 0 4
3 6 3 6
1 1 5 1
1 0 5 1
9 7 13 12 -> ito po sagot nila pag i-nad pababa