import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
/**
*
* @author Teka
*/
public class soal2b {
public static void main(String args[]) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int angka;
System.out.print("Masukkan angka : ");
angka = (Integer.parseInt(br.readLine()));
switch(angka){
case 1: System.out.println("Satu");
break;
case 2: System.out.println("Dua");
break;
case 3: System.out.println("Tiga");
break;
case 4: System.out.println("Empat");
break;
case 5: System.out.println("Lima");
break;
case 6: System.out.println("Enam");
break;
case 7: System.out.println("Tujuh");
break;
case 8: System.out.println("Delapan");
break;
case 9: System.out.println("Sembilan");
break;
case 10: System.out.println("Sepuluh");
break;
default: System.out.println("System eror");
break;
}
}
}
Senin, 17 Maret 2014
java
0 Response to "Contoh penggunaan fungsi switch pada java"
Posting Komentar