a. Sintak dalam program
package tugasomdono;
import
javax.swing.JOptionPane;
class overload{
private String no_mhs;
private String nama;
private int umur;
private String jurusan;
private String alamat;
private String kota;
String n;
void input()
{
no_mhs=JOptionPane.showInputDialog("masukan
no mahasiswa ");
nama=JOptionPane.showInputDialog("masukan
nama anda ");
n=JOptionPane.showInputDialog("masukan
umur anda");
umur=Integer.valueOf(n).intValue();
jurusan=JOptionPane.showInputDialog("masukan
jurusan kuliah anda ");
alamat=JOptionPane.showInputDialog("masukan
alamat anda ");
kota=JOptionPane.showInputDialog("masukan
kota anda ");
}
void satu()
{
System.out.println("overloading 1");
System.out.println("NIM : "+no_mhs);
System.out.println("Nama : "+nama);
System.out.println("Jurusan :
"+jurusan);
}
void satu(int i)
{
System.out.println("overloading 2");
System.out.println("Nama : "+nama);
System.out.println("Alamat : "+alamat);
System.out.println("Kota : "+kota);
}
void satu(int i,int b)
{
System.out.println("overloading 3");
System.out.println("NIM : "+no_mhs);
System.out.println("Nama : "+nama);
System.out.println("Umur : "+umur);
System.out.println("Alamat : "+alamat);
System.out.println("Kota : "+kota);
}
}
public class soal2 {
public static void main(String[] args) {
overload data=new overload();
data.input();
data.satu();
System.out.print("========================\n");
data.satu(1);
System.out.print("========================\n");
data.satu(1,1);
}
}
Hasil Pogram:
No comments:
Post a Comment