steef_br

Untitled

Apr 21st, 2021
58
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package MethodsMoreExercises;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class MultiplicationSign {
  6. public static void main(String[] args) {
  7. Scanner scanner = new Scanner(System.in);
  8.  
  9. int num1 = Integer.parseInt(scanner.nextLine());
  10. int num2 = Integer.parseInt(scanner.nextLine());
  11. int num3 = Integer.parseInt(scanner.nextLine());
  12.  
  13. findMultiplication(num1, num2, num3);
  14. }
  15.  
  16. private static void findMultiplication(int num1, int num2, int num3) {
  17.  
  18. if (num1 == 0 || num2 == 0 || num3 == 0) {
  19. System.out.println("zero");
  20. } else if (num1 > 0 && num2 > 0 && num3 > 0) {
  21. System.out.println("positive");
  22. } else {
  23. int negativeCount = 0;
  24. if (num1 < 0) {
  25. negativeCount += 1;
  26. }
  27. if (num2 < 0) {
  28. negativeCount += 1;
  29. }
  30. if (num3 < 0) {
  31. negativeCount += 1;
  32. }
  33. if (negativeCount == 2) {
  34. System.out.println("positive");
  35. } else if (negativeCount == 3) {
  36. System.out.println("negative");
  37. } else {
  38. System.out.println("negative");
  39. }
  40.  
  41. }
  42. }
  43. }
  44.  
RAW Paste Data