0% found this document useful (0 votes)
19 views1 page

Solution2 Exceptions Ferry

This Java program demonstrates exception handling by asking the user to repeatedly enter a number and handling any exceptions that occur. It prints messages for invalid integer values and asks the user if they want to continue the loop.

Uploaded by

Justine Grace
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views1 page

Solution2 Exceptions Ferry

This Java program demonstrates exception handling by asking the user to repeatedly enter a number and handling any exceptions that occur. It prints messages for invalid integer values and asks the user if they want to continue the loop.

Uploaded by

Justine Grace
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

/*

PROGRAMMED BY: JUSTINE GRACE FERRY


SECTION: IC2AA
TOPIC: PROBLEM 2 EXCEPTIONS
DATE SUBMITTED: 4/1/2022
*/

import java.util.Scanner;

public class Main {


public static void main (String[] args) {

Scanner me = new Scanner(System.in);

try {
char let;
int dog;
do{
System.out.println("_________________________________________");
System.out.println("| EXCEPTION HANDLING IN JAVA PROGRAMMING |");
System.out.println("+========================================+\n");
System.out.print("Enter A Number: ");
dog = me.nextInt();
System.out.println("The number you just given is "+dog);

System.out.println("\nDo you want to continue? (Type y or n)");


let = me.next().charAt(0);
}while(let == 'y' || let == 'Y');
if (let == 'n' || let == 'N');

}catch(Exception e) {
System.out.println("Invalid Integer Value!!.");
System.out.println("Try again....");
System.out.println("You must enter Integer value!!");
}
}
}

You might also like