/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package perhitungannilai;
/**
*
* @author Administrator
*/
public class Main {
public static void main(String[] args) {
mahasiswa mhs= new mahasiswa();
modeNilai md=new modeNilai(90, 90, 90, 90);
mhs.TamMahasiswa("093510166"," untung");
md.display();
System.out.println("========================================");
mahasiswa mhs1 = new mahasiswa();
modeNilai md1= new modeNilai(30, 40, 30, 10);
mhs1.TamMahasiswa("09351099","riki ");
md1.display();
}
}
------------------------------------------------------------------------------------------
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package perhitungannilai;
/**
*
* @author Administrator
*/
public class mahasiswa {
private String npm,nama;
public mahasiswa(){
}
public void mahasiswa(String npm,String nama){
this.npm=npm;
this.nama=nama;
}
public void TamMahasiswa(String npm,String nama){
System.out.println("npm = "+npm);
System.out.println("nama = "+nama);
}
}
-------------------------------------------------------------------------------------
/*
* To change this template, choose Tools | Templates
* and open the template in the editor.
*/
package perhitungannilai;
/**
*
* @author Administrator
*/
public class modeNilai {
private int tugas;
private int kuis;
private int mid;
private int sms;
String predikat;
public modeNilai(int tugas,int kuis,int mid,int sms){
this.tugas=tugas;
this.kuis=kuis;
this.mid=mid;
this.sms=sms;
}
double nilaiKuis(){
return kuis * 0.1;
}
double nilaiTugas(){
return tugas * 0.2;
}
double nilaiMid(){
return mid * 0.3;
}
double nilaiSms(){
return sms * 0.4;
}
double totalNilai(){
return nilaiKuis()+nilaiMid()+nilaiSms()+nilaiTugas();
}
public void display(){
System.out.println("nilai tugas= "+nilaiTugas());
System.out.println("nilai kuis = "+nilaiKuis());
System.out.println("nilai mid = "+nilaiMid());
System.out.println("niilai uas = "+nilaiSms());
System.out.println("total nilai= "+totalNilai());
if(totalNilai()>=90){
predikat="A";
}else if(totalNilai()>=75){
predikat="B";
}else if(totalNilai()>=60){
predikat="C";
}else{
predikat="D";
}
System.out.println("predikat = "+predikat);
}
}
0 comments:
Post a Comment