> > Nested If-Else

Nested If-Else

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

public class Nested_If_Else {
public static void main (String[] args){

InputStreamReader input = new InputStreamReader(System.in);
BufferedReader buf = new BufferedReader(input);

try{
System.out.println("Enter a number ! : ");
String strBil = buf.readLine();
int Bil = Integer.parseInt(strBil);

if (Bil>0){
if (Bil%2==0){
System.out.println("Bilangan GENAP POSITIF");
}
else{
System.out.println("Bilangan GANJIL POSITIF");
}
}
else if(Bil<0){
if (Bil%2==0){
System.out.println("Bilangan GENAP NEGATIF");
}
else{
System.out.println("Bilalngan GANJIL NEGATIF");
}
}
else{
System.out.println("Bilangan Anda 0");
}
}
catch(Exception ex){
System.out.println("System ERROR");
}
}
}

Leave a Reply

Powered by Blogger.