StefanTobler

Lesson 14 Activity 2

Oct 1st, 2016
114
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.69 KB | None | 0 0
  1. /*
  2.  * Lesson 14 Coding Activity 2
  3.  * Write a program to input two integers and print
  4.  * "Both are positive or zero." to the screen, if both are positive or zero.
  5.  * Print "One or both are negative." otherwise.
  6.  */
  7.  
  8.  
  9. import java.util.Scanner;
  10. import java.lang.Math;
  11. class Lesson_14_Activity_Two {
  12.     public static void main(String[] args)
  13.      {
  14.       Scanner scan = new Scanner(System.in);
  15.       int x = scan.nextInt();
  16.       int y = scan.nextInt();
  17.       if ((Math.abs(x)) == x && (Math.abs(y)) == y)
  18.       {
  19.         System.out.println("Both are positive or zero.");
  20.       }
  21.       else
  22.       {
  23.         System.out.println("One or both are negative.");
  24.       }
  25.      
  26.     }
  27. }
Add Comment
Please, Sign In to add comment