003-001-012
Using Modulus Operator
Medium
Problem Description
Using Modulus Operator
In this problem, you will create a program that reads three integers from standard input, uses the modulus operator (%) to determine whether integers are even or odd and to extract specific digits, and displays the result to standard output.
Learning Objective: Understand how to use the modulus operator (%) for calculating remainders and applications like even/odd checking
Overview
Read three integers with Scanner and use the modulus operator for even/odd checking and digit extraction.
Input
- Line 1: integer num1
- Line 2: integer num2
- Line 3: integer num3
Specifications
- Check and output whether num1 and num2 are even or odd
- Extract and output the last digit of num3
Output Format
{num1} is odd/even
{num2} is odd/even
Last digit of {num3} is {digit}
Sample Input/Output
Input:
17
24
456
Output:
17 is odd
24 is even
Last digit of 456 is 6
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