005-001-011
Determining Positive, Negative, or Zero with if
Easy
Problem Description
Determining Positive, Negative, or Zero with if
In this problem, you will create a program that reads one integer from standard input, uses if statements to determine whether it is positive, negative, or zero, and displays the result to standard output.
Learning Objective: Understand basic conditional branching with if statements
Overview
Create a program that reads an integer from standard input and determines whether it is positive, negative, or zero.
Specifications
- Read one integer
nfrom standard input - Define
checkNumber(int n)method - If
n > 0, printPositive - If
n < 0, printNegative - If
n == 0, printZero
Input Format
n
(one integer per line)
Output Format
Positive
or Negative or Zero
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