Pembrograman Berorientasi Objek
posted by: Muhamad Ade Kurniawan
import java.io.*;
public class Pemilihan4a{
byte nilAbsen=0, nilTugas=0, nilUTS=0, nilUAS=0;
BufferedReader objInput = new BufferedReader(new InputStreamReader(System.in));
void input(){
try{
System.out.println ("=================================================");
System.out.println ("\t\tInput Nilai Mahasiswa");
System.out.println ("=================================================");
System.out.print ("Nilai Absen\t :"); nilAbsen=Byte.parseByte(objInput.readLine());
System.out.print ("Nilai Tugas\t :"); nilTugas=Byte.parseByte(objInput.readLine());
System.out.print ("Nilai UTS\t :"); nilUTS=Byte.parseByte(objInput.readLine());
System.out.print ("Nilai UAS\t :"); nilUAS=Byte.parseByte(objInput.readLine());
}
catch(Exception e){
System.out.println ("Error: "+e);
}
}
void cetak(){
System.out.println ("===================================");
System.out.println ("\t\tInput Nilai Mahasiswa");
System.out.println ("===================================");
System.out.println ("Nilai Absen\t :"+nilAbsen);
System.out.println ("Nilai Tugas\t :"+nilTugas);
System.out.println ("Nilai UTS\t :" +nilUTS);
System.out.println ("Nilai UAS\t :" +nilUAS);
int total=((nilAbsen*10/100)+(nilTugas*20/100)+(nilUTS*30/100)+(nilUAS*40/100));
char grade = '-';
String predikat="-";
if (total >=85 && total <=100){
grade= 'A';
predikat="Sangat Baik";
}
else
if (total >=75 && total <=84){
grade='B';
predikat="Baik";
}
else
if (total >=65 && total <=74){
grade='C';
predikat="Cukup";
}
else
if (total >=55 && total <=64){
grade='D';
predikat="Kurang";
}
else
{
grade='E';
predikat="Bodoh Bale";
}
System.out.println ("===================================");
System.out.println ("Nilai Total :"+total);
System.out.println ("Grade :"+grade);
System.out.println ("Predikat : "+predikat);
System.out.println ("===================================");
}
public static void main(String[] args){
Pemilihan4a objInput=new Pemilihan4a();
objInput.input();
objInput.cetak();
}
}
0 comments:
Post a Comment