Sebelum anda mengcoding atau mengetik program ini anda harus memahami apa itu Array, saya sarankan anda tidak hanya copas codingnya lebih baik untuk mengetik sendiri karena dengan mengetik sendiri anda akan lebih paham.
Coding :
import javax.swing.JOptionPane;
public class array{
public static void main(String[]asd){
double[] uas = new double[100];
double[] uts = new double[100];
String[] nama = new String[100];
String[] nim = new String[100];
String[] nilaiHuruf = new String[100];
double[] nilai = new double[100];
String op = "";
int x=0; int z;
do{
nama[x] = JOptionPane.showInputDialog("Masukkan Nama");
nim[x] = JOptionPane.showInputDialog("Masukkan NIM");
uts[x] = Double.parseDouble(JOptionPane.showInputDialog("Masukkan Nilai UTS"));
uas[x] = Double.parseDouble(JOptionPane.showInputDialog("Masukkan UAS"));
nilai[x]=(uts[x]+uas[x])/2;
if(nilai[x]>=85)nilaiHuruf[x]="A";
else if(nilai[x]>=75)nilaiHuruf[x]="B";
else if(nilai[x]>=65)nilaiHuruf[x]="C";
else if(nilai[x]>=55)nilaiHuruf[x]="D";
else nilaiHuruf[x]="E";
x++;
op = JOptionPane.showInputDialog("Lagi (Y/T)");
if(op.equals("T")||op.equals("t")) z = 0;
else z = 1;
}while(z!=0);
System.out.println("=======================================================================");
System.out.println("No\tNim\t\tNama\t\tUts\tUas\tNilai\tGrade");
for(int y=0;y<x;y++){
System.out.println(y+"\t"+nim[y]+"\t"+nama[y]+"\t"+uts[y]+"\t"+uas[y]+"\t"+nilai[y]+"\t"+nilaiHuruf[y]);
}
System.out.println("=======================================================================");
}
}
Hasil
Coding :
import javax.swing.JOptionPane;
public class array{
public static void main(String[]asd){
double[] uas = new double[100];
double[] uts = new double[100];
String[] nama = new String[100];
String[] nim = new String[100];
String[] nilaiHuruf = new String[100];
double[] nilai = new double[100];
String op = "";
int x=0; int z;
do{
nama[x] = JOptionPane.showInputDialog("Masukkan Nama");
nim[x] = JOptionPane.showInputDialog("Masukkan NIM");
uts[x] = Double.parseDouble(JOptionPane.showInputDialog("Masukkan Nilai UTS"));
uas[x] = Double.parseDouble(JOptionPane.showInputDialog("Masukkan UAS"));
nilai[x]=(uts[x]+uas[x])/2;
if(nilai[x]>=85)nilaiHuruf[x]="A";
else if(nilai[x]>=75)nilaiHuruf[x]="B";
else if(nilai[x]>=65)nilaiHuruf[x]="C";
else if(nilai[x]>=55)nilaiHuruf[x]="D";
else nilaiHuruf[x]="E";
x++;
op = JOptionPane.showInputDialog("Lagi (Y/T)");
if(op.equals("T")||op.equals("t")) z = 0;
else z = 1;
}while(z!=0);
System.out.println("=======================================================================");
System.out.println("No\tNim\t\tNama\t\tUts\tUas\tNilai\tGrade");
for(int y=0;y<x;y++){
System.out.println(y+"\t"+nim[y]+"\t"+nama[y]+"\t"+uts[y]+"\t"+uas[y]+"\t"+nilai[y]+"\t"+nilaiHuruf[y]);
}
System.out.println("=======================================================================");
}
}
Hasil
2 Komentar untuk "Program Array Menentukan Nilai Dari Masukan Nilai UTS Dan UAS"
Maksih bang
Sama sama