019-003-005

Multiple Exception Handling: Input Data Validation

Medium

Problem Description

Multiple exception handling: Input Data Validation

In this problem, you will create a program that converts a string input to an integer, validates whether the value falls within the range 0–100, and displays the result to standard output.

Learning Objective: Understand how to handle different exceptions using multiple catch blocks

Convert string to number and check range in DataParser class.

Input

Line 1: String to convert

Output

Success: Parsed value: [value]
Number format error: Error: Invalid number format
Out of range (0-100): Error: Value out of range (0-100)

Example

Input:

50

Output:

Parsed value: 50

Ready to Try Running Code?

Log in to access the code editor and execute your solutions for this problem.

Don't have an account?

Sign Up