public class Mahasiswa {
private String noMhs;
private String nama;
private String jurusan;
private float ipk;
//konstruktor
public Mahasiswa(String no,String nama,String
jur, float ipk){
this.noMhs=no;
this.nama=nama;
this.jurusan=jur;
this.ipk=ipk;
}
public void tampil(){
System.out.println("====================");
System.out.println("No Mhs :
"+noMhs);
System.out.println("Nama : "+nama);
System.out.println("Jurusan :
"+jurusan);
System.out.println("ipk :
"+ipk);
System.out.println("===================="); }
//program inputan (program utama)
public static void main(String[] Args){
Scanner in = new Scanner(System.in);
System.out.println("====================");
System.out.println("Masukkan No
Mhs : ");
String no=in.nextLine();
System.out.println("Masukkan Nama
: ");
String nma=in.nextLine();
System.out.println("Masukkan
Jurusan : ");
String jrsn=in.nextLine();
System.out.println("Masukkan IPK :
");
float ip=in.nextFloat();
//membuat objek
Mahasiswa mh = new Mahasiswa(no, nma,
jrsn, ip);
mh.tampil();
} }
OUTPUT
====================
Masukkan No Mhs :
105410191
Masukkan Nama :
rasyid
Masukkan Jurusan :
Ti
Masukkan IPK :
4.00
====================
No Mhs : 105410191
Nama :Rasyid
Jurusan : Ti
ipk : 4.0
====================
Posted by 11/28/2013 03:19:00 am and have
0
comments
, Published at
No comments:
Post a Comment