Program switch case


import java.util.Scanner;
public class MyClass {
public static void main() {
int hari_ke;
  String hari;
  Scanner input = new Scanner(System.in);
  System.out.print(“masukan hari_ke;”);
  System.out.print(“\n”);

hari_ke = input.nextInt();
switch (hari_ke){
 case 1 :
    hari = “senin”;
break;
case 2 :
    hari = “selasa”;
break;
case 3 :
    hari = “rabu”;
break;
case 4 :
    hari = “kamis”;
break;
case 5 :
   hari = “jumat”;
break;
case 6 :
    hari = “sabtu”;
break;
default:
    hari = “minggu”;
break;
}

System.out.print(“hari_ke”);
System.out.print(hari_ke);
System.out.print(“adalah”);
System.out.print(hari);
System.out.print(“\n”);
return 0;
}
}

0 Response to " Program switch case "