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

  1. Read one integer n from standard input
  2. Define checkNumber(int n) method
  3. If n > 0, print Positive
  4. If n < 0, print Negative
  5. If n == 0, print Zero

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