Foto diatas adalah hasil eksekusi dari kode program berikut :
import java.util.Scanner;
public class arrayJaper {
public static void main(String[] args){
Scanner input=new Scanner(System.in);
int i,jumlahMp;
int y=1;
String nama,jurusan;
String mataPelajaran[]=new String[15];
String grade[]=new String[15];
int uts[]=new int[15];
int uas[]=new int[15];
double nilai[]=new double[15];
while (y == 1) {
try {
System.out.println("<>============================<>");
System.out.println(" Menghitung Nilai Mahasiswa");
System.out.println("<>============================<>");
System.out.print(" Masukan Jumlah Mata Pelajaran: ");
jumlahMp=input.nextInt();
{
if (jumlahMp>12)
System.out.println("Maaf, maksimal mata pelajaran hanya sampai 12");
y--;
}
System.out.println("<>============================<>");
System.out.print(" Nama : ");
nama=input.next();
System.out.print(" Jurusan : ");
jurusan=input.next();
System.out.println("<>============================<>");
for(i=1; i<=jumlahMp; i++){
System.out.print("\n Mata pelajaran ke-"+i+" : ");
mataPelajaran[i]=input.next();
System.out.print(" Nilai UTS : ");
uts[i]=input.nextInt();
System.out.print(" Nilai UAS : ");
uas[i]=input.nextInt();
nilai[i]=((uts[i]*0.7)+(uas[i]*0.3));
if (nilai[i]>=92) grade[i]="A";
else if (nilai[i]>=82) grade[i]="B";
else if (nilai[i]>=75) grade[i]="C";
else if (nilai[i]>=60) grade[i]="D";
else grade[i]="E";
}
System.out.println("\n<>============================<>");
System.out.println("\n\n Nama: "+nama+"");
System.out.println("<>===================================<>");
System.out.println(" Mata Pelajaran Nilai Grade");
System.out.println("<>===================================<>");
for(i=1;i<=jumlahMp;i++){
System.out.println(" "+mataPelajaran[i]+" "+nilai[i]+" "+grade[i]);
}
System.out.println("\n\n<>==========================================<>");
System.out.println(" Terima Kasih Telah Memercayakan Program Kami");
System.out.println("<>==========================================<>");
System.exit(0);
}catch (Exception e){
System.out.println("Tolong isi dengan benar");
}
}
}
}
0 Komentar