contoh program dengan mengunakan (switch case)
1. Switch case
Class praktek
{
public static void main (string args [ ] )
{
int point;
point = 1;
System.out.println (”=====================”);
switch (point) {
Case 4:
Case 3:
System.out.println(“ket: medali emas”);
break;
Case 2:
System.out.println(“ket: medali perak”);
break;
Case 1:
System.out.println(“ket: medali perunggu”);
break;
default;
System.out.println(“ket: tidak mendapat medali !”);
}
System.out.println(“=====================”);
}
}
contoh program dengan mengunakan (if else)
1. If else
Class praktek
{
public static void main ( string args [ ] )
{
int point;
point = 3;
System.out.println (“=====================”);
if(point <=3)
System.out.println(“ket: medali emas”);
else
System.out.println(“ket: medali perak”);
System.out.println(“ket: medali perunggu”);
System.out.println(“ket: tidak mendapat medali !”);
System.out.println(“=====================”);
)
)
Tidak ada komentar:
Posting Komentar