Source
Code :
import javax.swing.JOptionPane;
import java.io.*;
public class nilai
{
public static void main (String[]args)
{
String uts,uas,nama,nim,grade;
String pilihan="y";
int[] iuts = new int[50];
int[] iuas = new int[50];
int[] nAkhir = new int[50];
int[] no = new int[50];
boolean y=true;
int i=0;
System.out.println("No" + " NIM "+ " nama
" + " Nilai UTS " + " Nilai UAS " + " Nilai Akhir
" + " Grade " );
do
{
nim = JOptionPane.showInputDialog("Masukkan NIM
");
nama = JOptionPane.showInputDialog("Masukkan NAMA
");
uts = JOptionPane.showInputDialog("Masukkan Nilai
UTS ");
uas = JOptionPane.showInputDialog("Masukkan Nilai
UAS ");
pilihan = JOptionPane.showInputDialog("Mau
menambah data lagi(y/t)");
iuts[i] = Integer.parseInt(uts);
iuas[i] =
Integer.parseInt(uas);
nAkhir[i] =
(iuts[i]+iuas[i])/2;
if((nAkhir[i]<=100)&&(nAkhir[i]>=85))
grade="A";
else if ((nAkhir[i]<85)&&(nAkhir[i]>=75))
grade="B";
else if
((nAkhir[i]<75)&&(nAkhir[i]>=65))
grade="C";
else if
((nAkhir[i]<65)&&(nAkhir[i]>=50))
grade="D";
else if
(nAkhir[i]<50)
grade="E";
else {
grade="Salah memasukkan nilai XD";
}
System.out.println(
no[i]+" "+ nim +" "+ nama +"
"+ iuts[i] +" "+ iuas[i] +" "+
nAkhir[i] +" "+ grade+" ");
if("t".equals(pilihan))
y=false;
} while (y);
}
}
0 komentar:
Posting Komentar