Computer Science, asked by shayanirtiza76, 4 days ago

Input a number/value from the user, check whether it is negative or positive. If it is negative then convert it into a positive number.

Answers

Answered by Anonymous
0

Answer:

import java.util.Scanner;

class Numbers

{

public static void main(String[] args)

{

//Declaration

Scanner input = new Scanner(System.in);

int num;

//Prompt and accept a number from user

System.out.println("Enter a number: ");

num = input.nextInt();

//Display accordingly

if (num > 0)

{

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

}

if (num < 0)

{

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

    int positive_no = num * -1;

    System.out.println("The positive alternative of " + num + " is " +

                                          positive_no);

}

}

}

Answered by KnoflerRigor
0

Answer:

In python...

Explanation:

x=int(input("Enter a number:"))

if (x>0):

   print("The number is positive!")

else:

   print("The number is negetive! In positive the number will be ",abs(x))

Similar questions