Output
Source Codenya
package javaapplication12;
/**
*
* @author TOSHIBA
*/
import javax.swing.*;
class manusia{
private String manusia;
public void set_manusia(String nama) {
manusia = nama;
}
public String get_Manusia() {
return manusia;
}
}
class mahasiswa extends manusia {
private String npm;
private String mhs;
public void set_npm(String n) {
npm = n;
}
public String get_npm(){
return npm;
}
public void set_maha(String ipk) {
mhs = ipk;
}
public String get_mhs(){
return mhs;
}
}
class pekerja extends mahasiswa{
private String pekerja;
private String gaji;
public void set_pekerja(String nama) {
pekerja = nama;
}
public String get_pekerja(){
return pekerja;
}
public void set_gaji(String g) {
gaji = g;
}
public String get_gaji(){
return gaji;
}
}
public class Main {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
// TODO code application logic here
pekerja x = new pekerja();
x.set_manusia(JOptionPane.showInputDialog("Masukkan Nama"));
x.set_maha(JOptionPane.showInputDialog("Masukkan IPK"));
x.set_npm(JOptionPane.showInputDialog("Masukkan NPM"));
x.set_pekerja(JOptionPane.showInputDialog("Masukkan ID Pekerja"));
x.set_gaji(JOptionPane.showInputDialog("Masukkan Jumlah Gaji"));
//pemasukan data2
System.out.println("Nama : "+x.get_Manusia());
System.out.println("IPK : "+x.get_mhs());
System.out.println("NPM : "+x.get_npm());
System.out.println("ID pekerja : "+x.get_pekerja());
System.out.println("Jumlah Gaji/bulan : "+x.get_gaji());
}
}
Tidak ada komentar:
Posting Komentar