Hasil Output :
Code:
import javax.swing.JOptionPane;
public class JOptionPane_Array {
public static void main(String args[])
{
String N, msg, I;
double n[] = new double[10], nr, i, nt = 0;
I = JOptionPane.showInputDialog("Berapakah banyak data yang ingin anda inputkan?");
i = Integer.parseInt(I);
for (int X = 1; X <= i; X++)
{
N = JOptionPane.showInputDialog("Masukkan Nilai " + X);
n[X] = Integer.parseInt(N);
nt = nt + n[X];
}
nr = nt / i;
if (nr >= 60)
{
msg = "Nilai anda " + nr;
}
else
{
msg = "Rata-rata nilai anda adalah " + nr;
}
JOptionPane.showMessageDialog(null, msg);
}
}
Semoga bermanfaat,
Code:
import javax.swing.JOptionPane;
public class JOptionPane_Array {
public static void main(String args[])
{
String N, msg, I;
double n[] = new double[10], nr, i, nt = 0;
I = JOptionPane.showInputDialog("Berapakah banyak data yang ingin anda inputkan?");
i = Integer.parseInt(I);
for (int X = 1; X <= i; X++)
{
N = JOptionPane.showInputDialog("Masukkan Nilai " + X);
n[X] = Integer.parseInt(N);
nt = nt + n[X];
}
nr = nt / i;
if (nr >= 60)
{
msg = "Nilai anda " + nr;
}
else
{
msg = "Rata-rata nilai anda adalah " + nr;
}
JOptionPane.showMessageDialog(null, msg);
}
}
Semoga bermanfaat,
0 comments:
Post a Comment