class Mahasiswa
=====================================================================
class Mahasiswa{
//Properti
String NIM, nama;
double UTS, UAS;
//Metode Mutator
void setNIM(String NIM){
this.NIM = NIM;
}
void setNama(String nama){
this.nama = nama;
}
void setData(String NIM, String nama){
this.NIM = NIM;
this.nama = nama;
}
void setData(double UTS, double UAS){
this.UTS = UTS;
this.UAS = UAS;
}
//Metode Assesor
String getNIM(){
return this. NIM;
}
String getNama(){
return nama;
}
double getUTS(){
return UTS;
}
double getUAS(){
return UAS;
}
}
====================================================================
class Mahasiswa4DPagi
====================================================================
class Mahasiswa4DPagi{
public static void main(String args[]){
Mahasiswa Aji = new Mahasiswa();
Mahasiswa Alif = new Mahasiswa();
Aji.setNIM("1234567");
Aji.setNama("Aji Nugroho");
Aji.setData(66.66,77.77);
Alif.setData("8347", "Alif Wingkara");
Alif.setData(67.67,76.76);
System.out.println("NIM : "+Aji.getNIM());
System.out.println("Nama : "+Aji.getNama());
System.out.println("UTS : "+Aji.getUTS());
System.out.println("UAS : "+Aji.getUAS());
System.out.println();
System.out.println("NIM : "+Alif.getNIM());
System.out.println("Nama : "+Alif.getNama());
System.out.println("UTS : "+Alif.getUTS());
System.out.println("UAS : "+Alif.getUAS());
}
}
Tidak ada komentar