Advertisement
Guest User

Untitled

a guest
Apr 23rd, 2019
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. import java.util.Scanner;
  2.  
  3. public class TwoNumbers {
  4. public static void main(String[] args) {
  5. Scanner scanner = new Scanner(System.in);
  6. System.out.println("Enter first integer");
  7. int num1= scanner.nextInt();
  8. scanner.nextLine();
  9. System.out.println("Enter second integer");
  10. int num2 = scanner.nextInt();
  11. System.out.println("Your first number is: " + num1);
  12. System.out.println("Your second number is: " + num2);
  13. if ((num1 <= 0 && num2 > 0) || (num1 > 0 && num2 <= 0)) {
  14. System.out.println("The product of two numbers is: " + String.valueOf(num1 * num2));
  15. } else {
  16. if (num1 > num2)
  17. System.out.println("The difference of two numbers is: " + String.valueOf(num1 - num2));
  18. if (num1 < 0 && num2 < 0)
  19. System.out.println("The sum of two numbers is: " + String.valueOf(num1 + num2));
  20. else if(num2 != 0){
  21. System.out.println("The modulo of first to second number is: " + String.valueOf(num1 % num2));
  22. }
  23. }
  24. }
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement