JAVA | LATIHAN | TUGAS

// program penghitung nilai mahasiswa dan rata-rata kelas

// berikut ini program sederhana yang saya dapatkan dikuliah

// maklum masih pemula dan belum tau banyak tentang programming

//semoga berguna bagi para pemula2 seperti saya….

import java.io.*;
import javax.swing.JOptionPane;

class Nilai{
public static void main(String[]args)throws Exception{
System.out.println(“Program penghitung nilai mahasiswa”);
System.out.println(“==================================”);

BufferedReader inputan = new BufferedReader (new InputStreamReader(System.in));

String nama;
int n=0,ulang;
double rata2,nilai,Total=0;

try{
System.out.print(“>> Masukkan jumlah mahasiswa: “);
n = Integer.parseInt(inputan.readLine());
}

catch(Exception e){ System.out.println(“Masukkan angka saja bozz”); }
System.out.println();

ulang = 0;

try{

do
{
System.out.println();
System.out.print(“Masukkan Nama Mahasiswa: “);
nama = inputan.readLine();
System.out.print(“Masukkan Nilai Mahasiswa: “);
nilai = Integer.parseInt(inputan.readLine());
System.out.println(“———————“);
System.out.println(“Mahasiswa bernama “+nama);
if (nilai==0){System.out.print(“Nilai E”);}
else if(nilai<=50){System.out.println(“Nilai D “);}
else if (nilai<=60){System.out.println(“Nilai C- “);}
else if (nilai<=65){System.out.println(“Nilai C “);}
else if (nilai<=70){System.out.println(“Nilai C+ “);}
else if(nilai<=75){System.out.println(“Nilai B- “);}
else if(nilai <=80){System.out.println(“Nilai B “);}
else if (nilai <=85){System.out.println(“Nilai B+ “);}
else if (nilai <=90){System.out.println(“Nilai A- “);}
else if (nilai <=95){System.out.println(“Nilai A “);}
else if (nilai<=100){System.out.println(“Nilai A+ “);}
else System.out.print(“Inputan tidak valid”);

Total+= nilai;
rata2 = Total / n;
ulang++;
}

while (ulang<n);
System.out.println();
System.out.println(“Rata-rata kelas” + rata2);
JOptionPane.showMessageDialog(null,”RATA-RATA KELAS ADALAH “+ rata2,”Rata-rata kelas”,JOptionPane.INFORMATION_MESSAGE);
}
catch(Exception e) {System.out.println(“Masukkan angka saja bozz”); }
System.exit(0);
}
}

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: