==========================
import java.util.Scanner;
import java.io.*;
public class Nilai_Rata2 {
public static void main (String [] eee) {
Scanner M = new Scanner (System.in);
int N,x,i,tot=0;
float rata2;
long NPM;
System.out.print("Masukan Nama Mahasiswa = ");
try {
BufferedReader nama = new BufferedReader(new
InputStreamReader(System.in));
String mhsw = nama.readLine();
} catch (IOException e) {
System.out.println("ERROR");
}
System.out.print("Masukan NPM = ");
NPM = M.nextLong();
System.out.println();
System.out.print("Masukan Jumlah Mata Kuliah = ");
N = M.nextInt();
for (i=1; i<=N; i++) {
System.out.print("Masukan Nilai Mata Kuliah
ke-"+i+" = ");
x = M.nextInt ();
tot = tot + x;
}
System.out.println("=========================================");
rata2 = tot /N ;
System.out.println("Nilai Rata-Rata Mata Kuliah =
"+rata2);
if (rata2>=90) { System.out.println("GRADE A");
}
else if (rata2>=80 && rata2<=89) {
System.out.println("GRADE B"); }
else if (rata2>=70 && rata2<=79) {
System.out.println("GRADE C"); }
else if (rata2>=60 && rata2<=69) {
System.out.println("GRADE D"); }
else { System.out.println("GRADE E"); }
}
}
No comments:
Post a Comment