Kelas : 2KB03
NPM : 26110064
PROGRAM SEDERHANA JAVA
public class hari {
public static void main (String [] args){
hari a = new hari ();
a.NB= 1;
a.hari ();
hari b = new hari ();
b.NB= 2;
b.hari ();
hari c = new hari ();
c.NB= 3;
c.hari ();
hari d = new hari ();
d.NB= 4;
d.hari ();
hari e = new hari ();
e.NB= 5;
e.hari ();
hari f = new hari ();
f.NB= 6;
f.hari ();
hari g = new hari ();
g.NB= 7;
g.hari ();
}
}
class hari{
int NB;
String NC;
void hari (){
if (NB==1)
NC = "senin";
else if (NB==2)
NC = "selasa";
else if (NB==3)
NC ="rabu";
else if (NB==4)
NC ="ksmis";
else if (NB==5)
NC ="jum'at";
else if (NB==6)
NC ="sabtu";
else if (NB==7)
NC ="minggu";
System.out.println ("Nama Hari "+NC);
}
}
Tidak ada komentar:
Posting Komentar