1. Welcome to PHCorner Forums. Take a moment to Sign up and gain unlimited access and extra privileges that guests are not entitled to, such as:

    All that and more! Registration is quick, simple and absolutely free. Join our community today!

Java Pahelp po tnx .

Discussion in 'Coding, Programming' started by dj_andia, Oct 29, 2015.

  1. 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
     
  2. nakalimutan ko na po yan.. pero try ko. hehe
     
  3. tnx in advance boss..
     
Tags / Keywords: