Java switch case

import java.util.Scanner;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.IOException;

public class switch_case
{
 public static void main(String[] argumen){
 
 
 
 while(true){
 
 
 int indeks = 0;
 String ul="";
 
 BufferedReader dataInput = new BufferedReader(new InputStreamReader(System.in));
 
 
 try{
 Scanner s = new Scanner(System.in);
 System.out.print("masukkan nilai index angka (1,2,3,4,5) : ");
 indeks = Integer.parseInt(dataInput.readLine());
 
 switch(indeks){
 case 1:
 System.out.println("Nilai Anda sangat baik");
 break;
 case 2:
 System.out.println("Nilai Anda baik");
 break;
 case 3:
 System.out.println("Nilai Anda cukup");
 break;
 case 4:
 System.out.println("Nilai Anda kurang");
 break;
 case 5:
 System.out.println("Nilai Anda sangat kurang");
 break;
 default:
 System.out.println("salah input nilai indeks");
 break;
 }
 
 System.out.print("input lagi? yes/no : ");
 ul = dataInput.readLine();
 
 
 if(ul.equalsIgnoreCase("yes")){
 }else{
 break;
 }
 
 }catch(IOException e){
 System.out.println("terjadi kesalahan pada Inputan");
 }

 
 }
 
 }
}

You may also like...

Leave a Reply

Your email address will not be published. Required fields are marked *