ENCAPSULATION ( PBO )
NAMA : EKO HARYADI
KELAS : TK 19 A
NPM : 19316029
public class Mahasiswa {
private String Npm;
private String Nama;
private String Alamat;
private String Nohp;
private String Email;
private String IG;
public String getNpm(){
return Npm;
}
public void setNpm (String Npm){
this.Npm = Npm;
}
public String getNama(){
return Nama;
}
public void setNama(String Nama){
this.Nama = Nama;
}
public String getAlamat(){
return Alamat;
}
public void setAlamat (String Alamat){
this.Alamat = Alamat;
}
public String getNohp(){
return Nohp;
}
public void setNohp (String Nohp){
this.Nohp = Nohp;
}
public String getEmail(){
return Email;
}
public void setEmail (String Email){
this.Email = Email;
}
public String getIG(){
return IG;
}
public void setIG (String IG){
this.IG = IG;
}
}
import java.util.Scanner;
public class Mahasiswamain {
public static void main(String[] args) {
Mahasiswa mhs = new Mahasiswa ();
Scanner input = new Scanner (System.in);
System.out.print("Masukakan Npm : ");
mhs.setNpm(input.nextLine());
System.out.print("Masukkan Nama: ");
mhs.setNama(input.nextLine());
System.out.print("Masukkan Alamat: ");
mhs.setAlamat(input.nextLine());
System.out.print("Masukkan No Hp: ");
mhs.setNohp(input.nextLine());
System.out.print("Masukkan Email: ");
mhs.setEmail(input.nextLine());
System.out.print("Masukkan Instagram: ");
mhs.setIG(input.nextLine());
System.out.println("Npm : "+mhs.getNpm());
System.out.println("Nama: "+mhs.getNama());
System.out.println("Alamat: "+mhs.getAlamat());
System.out.println("No Hp: "+mhs.getNohp());
System.out.println("Email: "+mhs.getEmail());
System.out.println("Instagram "+mhs.getIG());
}
}
Komentar
Posting Komentar