002-004-009
Age Input Validation Program
Medium
Problem Description
Age Input Validation Program
Learning Objective: Understand how to receive user input, convert to appropriate type, and validate
Overview
Create a program that receives age as input from the user and validates whether the value is valid. Learn the basics of input value range checking.
Specifications
- Receive one integer (age) from standard input
- If the input value is between 0 and 120 inclusive, output
Valid age: {input value} - Otherwise, output
Invalid age
Input Format
25
Output Format
If input is valid:
Valid age: 25
If input is invalid:
Invalid age
Hints
- Use
Scannerto receive integer input - Use
ifstatement to check the range
Ready to Try Running Code?
Log in to access the code editor and execute your solutions for this problem.
Don't have an account?
