Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /*
- * Lesson 14 Coding Activity 2
- * Write a program to input two integers and print
- * "Both are positive or zero." to the screen, if both are positive or zero.
- * Print "One or both are negative." otherwise.
- */
- import java.util.Scanner;
- import java.lang.Math;
- class Lesson_14_Activity_Two {
- public static void main(String[] args)
- {
- Scanner scan = new Scanner(System.in);
- int x = scan.nextInt();
- int y = scan.nextInt();
- if ((Math.abs(x)) == x && (Math.abs(y)) == y)
- {
- System.out.println("Both are positive or zero.");
- }
- else
- {
- System.out.println("One or both are negative.");
- }
- }
- }
Add Comment
Please, Sign In to add comment