Java Basic Activities: Try Catch w/ nested else if statement | Invalid Character




=============================
Code: 
==============================

import java.util.Scanner;

public class Test31_Pereda_Challege {

public static void main(String [] args) {


int pvail;
Scanner input = new Scanner(System.in);

try {

System.out.println("Enter a number:");
pvail = input.nextInt();




if (pvail <= -1) {
System.out.println("The number you entered is negative");

}


else if (pvail >= 1) {
System.out.println("The number you entered is positive");

}

else if (pvail == 0) {
System.out.println("The number you entered is zero");

}


} catch (Exception e) {
System.out.println("Character are not allowed!!!!");

input.close();

}

}

}




========================================================













Walang komento:

Mag-post ng isang Komento