import java.io.*;
class Mahasiswa {
private String NPM,nama;
private double nilaiKuis,nilaiTugas,nilaiUTS,nilaiUAS;
//constructor pertama
public Mahasiswa(){
this.nama="-";
this.NPM="-";
}
//constructor ke-2
public Mahasiswa(String NPM,String nama){
this.nama=nama;
this.NPM=NPM;
}
//constructor ke-3
public Mahasiswa(String NPM,String nama,double nilaiKuis,double nilaiTugas, double nilaiUTS,double nilaiUAS){
this.nama=nama;
this.NPM=NPM;
this.nilaiKuis=nilaiKuis;
this.nilaiTugas=nilaiTugas;
this.nilaiUTS=nilaiUTS;
this.nilaiUAS=nilaiUAS;
}
//method setter
public void setNPM(String NPM){
this.NPM=NPM;
}public void setNama(String nama){
this.nama=nama;
}public void setNilaiKuis(double nilaiKuis){
this.nilaiKuis=nilaiKuis;
}public void setNilaiTugas(double tugas){
this.nilaiTugas=tugas;
}public void setNilaiUTS(double UTS){
this.nilaiUTS=UTS;
}public void setNilaiUAS(double UAS){
this.nilaiUAS=UAS;
}
public String getNPM(){
return this.NPM;
}public String getNama(){
return this.nama;
}public double getNilaiKuis(){
return this.nilaiKuis;
}public double getNilaiTugas(){
return this.nilaiTugas;
}public double getNilaiUTS(){
return this.nilaiUTS;
}public double getNilaiUAS(){
return this.nilaiUAS;
}
public void infoMahasiswa(){
System.out.println("=================================");
System.out.println("NPM = "+this.NPM);
System.out.println("Nilai Akhir = "+getJurusan());
System.out.println("Nama = "+this.nama);
System.out.println("Nilai Kuis = "+this.nilaiKuis);
System.out.println("Nilai Tugas = "+this.nilaiTugas);
System.out.println("Nilai UTS = "+this.nilaiUTS);
System.out.println("Nilai UAS = "+this.nilaiUAS);
System.out.println("Nilai Akhir = "+getNilaiAkhir());
System.out.println("Nilai Akhir = "+getGrade());
}
public double getNilaiAkhir(){
return(this.nilaiKuis*0.1)+(this.nilaiTugas*0.2)+(this.nilaiUTS*0.3)+(this.nilaiUAS*0.4);
}
public String getGrade(){
if(getNilaiAkhir()<45){
return "E";
}
else if(getNilaiAkhir() < 55){
return "D";
}else if(getNilaiAkhir() < 68){
return "C";
}else if(getNilaiAkhir() < 80){
return "B";
}else {
return "A";
}
}
public String getJurusan(){
if(this.NPM.substring(4,6).equalsIgnoreCase("25")){
return "Teknik Informatika";
}
else if(this.NPM.substring(4,6).equalsIgnoreCase("24")){
return "Sistem Informasi";
}
else{
return "Belum Ada";
}
}
}
public class OOP4 {
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Mahasiswa andi=new Mahasiswa();
System.out.print("Masukkan NPM = ");
String npm=br.readLine();
System.out.print("Masukkan Nama = ");
String nama=br.readLine();
System.out.print("Masukkan Nilai Kuis = ");
int kuis=Integer.parseInt(br.readLine());
System.out.print("Masukkan Nilai Tugas = ");
int tugas=Integer.parseInt(br.readLine());
System.out.print("Masukkan Nilai UTS = ");
int UTS=Integer.parseInt(br.readLine());
System.out.print("Masukkan Nilai UAS = ");
int UAS=Integer.parseInt(br.readLine());
andi.setNPM(npm);
andi.setNama(nama);
andi.setNilaiKuis(kuis);
andi.setNilaiTugas(tugas);
andi.setNilaiUTS(UTS);
andi.setNilaiUAS(UAS);
andi.infoMahasiswa();
}
}
class Mahasiswa {
private String NPM,nama;
private double nilaiKuis,nilaiTugas,nilaiUTS,nilaiUAS;
//constructor pertama
public Mahasiswa(){
this.nama="-";
this.NPM="-";
}
//constructor ke-2
public Mahasiswa(String NPM,String nama){
this.nama=nama;
this.NPM=NPM;
}
//constructor ke-3
public Mahasiswa(String NPM,String nama,double nilaiKuis,double nilaiTugas, double nilaiUTS,double nilaiUAS){
this.nama=nama;
this.NPM=NPM;
this.nilaiKuis=nilaiKuis;
this.nilaiTugas=nilaiTugas;
this.nilaiUTS=nilaiUTS;
this.nilaiUAS=nilaiUAS;
}
//method setter
public void setNPM(String NPM){
this.NPM=NPM;
}public void setNama(String nama){
this.nama=nama;
}public void setNilaiKuis(double nilaiKuis){
this.nilaiKuis=nilaiKuis;
}public void setNilaiTugas(double tugas){
this.nilaiTugas=tugas;
}public void setNilaiUTS(double UTS){
this.nilaiUTS=UTS;
}public void setNilaiUAS(double UAS){
this.nilaiUAS=UAS;
}
public String getNPM(){
return this.NPM;
}public String getNama(){
return this.nama;
}public double getNilaiKuis(){
return this.nilaiKuis;
}public double getNilaiTugas(){
return this.nilaiTugas;
}public double getNilaiUTS(){
return this.nilaiUTS;
}public double getNilaiUAS(){
return this.nilaiUAS;
}
public void infoMahasiswa(){
System.out.println("=================================");
System.out.println("NPM = "+this.NPM);
System.out.println("Nilai Akhir = "+getJurusan());
System.out.println("Nama = "+this.nama);
System.out.println("Nilai Kuis = "+this.nilaiKuis);
System.out.println("Nilai Tugas = "+this.nilaiTugas);
System.out.println("Nilai UTS = "+this.nilaiUTS);
System.out.println("Nilai UAS = "+this.nilaiUAS);
System.out.println("Nilai Akhir = "+getNilaiAkhir());
System.out.println("Nilai Akhir = "+getGrade());
}
public double getNilaiAkhir(){
return(this.nilaiKuis*0.1)+(this.nilaiTugas*0.2)+(this.nilaiUTS*0.3)+(this.nilaiUAS*0.4);
}
public String getGrade(){
if(getNilaiAkhir()<45){
return "E";
}
else if(getNilaiAkhir() < 55){
return "D";
}else if(getNilaiAkhir() < 68){
return "C";
}else if(getNilaiAkhir() < 80){
return "B";
}else {
return "A";
}
}
public String getJurusan(){
if(this.NPM.substring(4,6).equalsIgnoreCase("25")){
return "Teknik Informatika";
}
else if(this.NPM.substring(4,6).equalsIgnoreCase("24")){
return "Sistem Informasi";
}
else{
return "Belum Ada";
}
}
}
public class OOP4 {
public static void main(String[] args) throws IOException{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
Mahasiswa andi=new Mahasiswa();
System.out.print("Masukkan NPM = ");
String npm=br.readLine();
System.out.print("Masukkan Nama = ");
String nama=br.readLine();
System.out.print("Masukkan Nilai Kuis = ");
int kuis=Integer.parseInt(br.readLine());
System.out.print("Masukkan Nilai Tugas = ");
int tugas=Integer.parseInt(br.readLine());
System.out.print("Masukkan Nilai UTS = ");
int UTS=Integer.parseInt(br.readLine());
System.out.print("Masukkan Nilai UAS = ");
int UAS=Integer.parseInt(br.readLine());
andi.setNPM(npm);
andi.setNama(nama);
andi.setNilaiKuis(kuis);
andi.setNilaiTugas(tugas);
andi.setNilaiUTS(UTS);
andi.setNilaiUAS(UAS);
andi.infoMahasiswa();
}
}
Comments
Post a Comment