- int a=1; int x=0;
switch(a) {
case 1: {
x+=5;
break;
}
case 2: {
x+=10;
break;
}
case 3: {
x+=16;
break;
}
case 4: {
x+=34;
break;
}
} - import java.util.Scanner;
public class TernOperator{
public static void main(String[] args){
Scanner inNilai = new Scanner(System.in);
int n;
boolean c;do{
c = true;
System.out.print(“Input nilai [0..100]: “);
try{
n = inNilai.nextInt();
if(n<0||n>100){
System.out.println(“Wrong input.”);
c = false;
}else{
if(n>65) System.out.println(“Passed”);
else System.out.println(“Failed”);
}
}catch(Exception e){
System.out.println(“Input must be a number!”);
c = false;
inNilai = new Scanner(System.in);
}
}while(!c);
}
}
-
Recent Posts
Recent Comments
- Anonymous on Hello world!
Archives
Categories
Meta