From 92cc0271fdb757257edda0e265848afa6bb47c57 Mon Sep 17 00:00:00 2001 From: shreeniryu <110728767+shreeniryu@users.noreply.github.com> Date: Sat, 6 Aug 2022 19:35:39 +0530 Subject: [PATCH] Update CheckIfTheNumberIsPositiveOrNegative.java Please review and let know if there is more easy way to achieve this. Thanks --- .../CheckIfTheNumberIsPositiveOrNegative.java | 36 ++++++++++--------- 1 file changed, 19 insertions(+), 17 deletions(-) diff --git a/week1/day1/assignments/CheckIfTheNumberIsPositiveOrNegative.java b/week1/day1/assignments/CheckIfTheNumberIsPositiveOrNegative.java index f0eebab..8123620 100644 --- a/week1/day1/assignments/CheckIfTheNumberIsPositiveOrNegative.java +++ b/week1/day1/assignments/CheckIfTheNumberIsPositiveOrNegative.java @@ -1,20 +1,22 @@ package week1.day1; -public class CheckIfTheNumberIsPositiveOrNegative { -public static void main(String[] args) { - - //Problem statement: Check if the number is positive or negative - /*Pseudocode - * : ---------- - * 1. Initialize a number, say, int number= 35; - * - * 2. If a number is positive, print "The number is positive" - * - * If a number is negative, print "The number is negative" - * - * If it nether negative nor positive, print as - * - * "The number is neither positive nor negative" - */ -} +public class CheckIfTheNumberIsPositiveOrNegative +{ + public static void main(String[] args) + { + int number = 35; + if(number>0) + { + System.out.println("The number is positive"); + } + else if(number<0) + { + System.out.println("The number is negative"); + } + else + { + System.out.println("The number is neither negative nor positive"); + } + } } +