Di program ini anda hanya tinggal mesukkan codingnya,ingat yang di complile yaitu Tesorang.
Class Orang
public class orang{
String depan;
String belakang;
int usia;
void tampil (){
System.out.print("nama "+depan+" "+belakang+", berusia : "+usia+" tahun");
System.out.println();
}
}
Class Method Main tesorang
public class tesorang {
public static void main(String[]args){
orang org1=new orang();
orang org2=new orang();
orang org3=new orang();
orang org4=new orang();
int i;
System.out.println("Data orang 1: ");
System.out.print("Nama Depan: ");org1.depan=System.console().readLine();
System.out.print("Nama Belakang: ");org1.belakang=System.console().readLine();
System.out.print("Usia: ");org1.usia=Integer.parseInt(System.console().readLine());
System.out.println();
System.out.println("Data orang 2: ");
System.out.print("Nama Depan: ");org2.depan=System.console().readLine();
System.out.print("Nama Belakang: ");org2.belakang=System.console().readLine();
System.out.print("Usia: ");org2.usia=Integer.parseInt(System.console().readLine());
System.out.println();
System.out.println("Data orang 3: ");
System.out.print("Nama Depan: ");org3.depan=System.console().readLine();
System.out.print("Nama Belakang: ");org3.belakang=System.console().readLine();
System.out.print("Usia: ");org3.usia=Integer.parseInt(System.console().readLine());
System.out.println();
System.out.println("Data orang 4: ");
System.out.print("Nama Depan: ");org4.depan=System.console().readLine();
System.out.print("Nama Belakang: ");org4.belakang=System.console().readLine();
System.out.print("Usia: ");org4.usia=Integer.parseInt(System.console().readLine());
System.out.println();
org1.tampil();
org2.tampil();
org3.tampil();
org4.tampil();
}
}
ScreenShot
Class Orang
public class orang{
String depan;
String belakang;
int usia;
void tampil (){
System.out.print("nama "+depan+" "+belakang+", berusia : "+usia+" tahun");
System.out.println();
}
}
Class Method Main tesorang
public class tesorang {
public static void main(String[]args){
orang org1=new orang();
orang org2=new orang();
orang org3=new orang();
orang org4=new orang();
int i;
System.out.println("Data orang 1: ");
System.out.print("Nama Depan: ");org1.depan=System.console().readLine();
System.out.print("Nama Belakang: ");org1.belakang=System.console().readLine();
System.out.print("Usia: ");org1.usia=Integer.parseInt(System.console().readLine());
System.out.println();
System.out.println("Data orang 2: ");
System.out.print("Nama Depan: ");org2.depan=System.console().readLine();
System.out.print("Nama Belakang: ");org2.belakang=System.console().readLine();
System.out.print("Usia: ");org2.usia=Integer.parseInt(System.console().readLine());
System.out.println();
System.out.println("Data orang 3: ");
System.out.print("Nama Depan: ");org3.depan=System.console().readLine();
System.out.print("Nama Belakang: ");org3.belakang=System.console().readLine();
System.out.print("Usia: ");org3.usia=Integer.parseInt(System.console().readLine());
System.out.println();
System.out.println("Data orang 4: ");
System.out.print("Nama Depan: ");org4.depan=System.console().readLine();
System.out.print("Nama Belakang: ");org4.belakang=System.console().readLine();
System.out.print("Usia: ");org4.usia=Integer.parseInt(System.console().readLine());
System.out.println();
org1.tampil();
org2.tampil();
org3.tampil();
org4.tampil();
}
}
ScreenShot
0 Komentar untuk "Progam Membuat Class Orang Dan Class Method Main orang "