kelas:TK 19
Npm:19316085
Class mahasiswa (assignment 1)
public class mahasiswa {
//membuat atribut class
private String NPM;
private String NAMA;
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;
}
}
main_mahasiswa
import java.util.Scanner;
public class main_mahasiswa {
public static void main(String[] args) {
Scanner bayu = new Scanner (System.in);
String NPM,NAMA;
mahasiswa objmhs = new mahasiswa();
System.out.print("Masukan NPM : ");
NPM= bayu.nextLine();
objmhs.setNPM(NPM);
objmhs.getNPM();
System.out.print("Masukan NAMA : ");
NAMA= bayu.nextLine();
objmhs.setNAMA(NAMA);
objmhs.getNAMA();
}
}
Main Class (assignment 2)
public class mahasiswa {
//membuat atribut class
private String NPM;
private String NAMA;
private String ALAMAT;
private String NoHP ;
private String EMAIL;
private String INSTAGRAM;
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 getINSTAGRAM(){
return INSTAGRAM;
}
public void setINSTAGRAM(String INSTAGRAM){
this.INSTAGRAM = INSTAGRAM;
}
}
Main_mahasiswa
import java.util.Scanner;
public class main_mahasiswa {
public static void main(String[] args) {
Scanner bayu= new Scanner (System.in);
String NPM,NAMA,ALAMAT,NoHP,EMAIL,INSTAGRAM;
mahasiswa objmhs = new mahasiswa();
System.out.print("Masukan NPM : ");
NPM= bayu.nextLine();
objmhs.setNPM(NPM);
objmhs.getNPM();
System.out.print("Masukan NAMA : ");
NAMA= bayu.nextLine();
objmhs.setNAMA(NAMA);
objmhs.getNAMA();
System.out.print("Masukan ALAMAT : ");
ALAMAT= bayu.nextLine();
objmhs.setALAMAT(ALAMAT);
objmhs.getALAMAT();
System.out.print("Masukan NoHP : ");
NoHP= bayu.nextLine();
objmhs.setNoHP(NoHP);
objmhs.getNoHP();
System.out.print("Masukan EMAIL : ");
EMAIL= bayu.nextLine();
objmhs.setEMAIL(EMAIL);
objmhs.getEMAIL();
System.out.print("Masukan INSTAGRAM : ");
INSTAGRAM= bayu.nextLine();
objmhs.setINSTAGRAM(INSTAGRAM);
objmhs.getINSTAGRAM();
}
}
Sekian dan terimakasih
Tidak ada komentar:
Posting Komentar