tahsinjahanriza2001
tahsinjahanriza2001 tahsinjahanriza2001
  • 23-09-2021
  • Computers and Technology
contestada

The variable "num" holds an integer user input
Write a conditional statement that does the following:

If num is positive, print "__ is positive"
If num is negative, print "__ is negative"

Respuesta :

dragon1524
dragon1524 dragon1524
  • 23-09-2021

Answer:

import java.util.*;

class Main {

  public static void main(String[] args) {

         Scanner inp = new Scanner(System.in);

         System.out.print("In");

         int num = inp.nextInt();

         if(num>0) {

                   System.out.println(num + "is positive");

         }

         else if(num < 0) {

                    System.out.println.(num+ "is negative");

        }

        }

}

Answer Link

Otras preguntas

85% of the eighth graders are going on the class trip. What decimal is 85% equivalent to?
who were the Mycenaeans?
which of the following is example of a reserved power
how many times does 40 go into 256?
Physical activity and exercise typically lead to __________. a. increased stress b. depression c. higher energy levels d. reduced quality of life
sandra writes (4x30) + (4x2) and says the quotient for 128 + 4 is 8. is she correct? explain.
How did most people in new england earn a living
Which word in the sentence does the adverb modify several people ran toward the stairs, while others quickly walked to the elevator. A.walked B.stairs C.peopl
12.13 in word form and expanded form
Fill in the blank. The blank brace relieved the pain from his injury