002-002-009

Numeric Input: Age Calculation

Easy

Problem Description

Numeric Input: Age Calculation

In this problem, you will create a program that reads the current year and birth year using the Scanner class, calculates the age as their difference, and displays the result to standard output.

Learning Objective: Understand how to read integer values using the Scanner class and use them in calculations

Overview

Create a program that uses the Scanner class to receive the current year and birth year as input, calculates the age, and outputs it.

Specifications

  • Read the current year (integer) from the first line
  • Read the birth year (integer) from the second line
  • Calculate age (current year - birth year)
  • Output in the format "Age: [age]"

Input Format

2024
2000

Output Format

Age: 24

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