Advertisement
Ragnard-Kiseki-

RelationalOperators

May 17th, 2021
38
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 4.79 KB | None | 0 0
  1. package prelimactivities.laboratoryActivity_5;
  2.  
  3. import java.util.Scanner;
  4.  
  5. public class RelationalOperators {
  6.  
  7. public static void main(String[] args) {
  8. // Create a Scanner
  9. Scanner input = new Scanner(System.in);
  10.  
  11. //Prompt the user to enter a number.
  12. System.out.println("Enter your number: ");
  13. int operand1 = input.nextInt();
  14. int operand2 = input.nextInt();
  15. int operand3 = input.nextInt();
  16. int operand4 = input.nextInt();
  17. int operand5 = input.nextInt();
  18. int operand6 = input.nextInt();
  19. int operand7 = input.nextInt();
  20. int operand8 = input.nextInt();
  21. int operand9 = input.nextInt();
  22. int operand10 = input.nextInt();
  23. int operand11 = input.nextInt();
  24. int operand12 = input.nextInt();
  25. input.close();
  26.  
  27. //Display the relationship of the operand 1 and operand 2
  28. System.out.println("\n");
  29. if (operand1 == operand2)
  30. System.out.println("1st number and 2nd number are equal.");
  31. if (operand1 >= operand2)
  32. System.out.println("1st number is greater than or equal to 2nd number.");
  33. if(operand1 <= operand2)
  34. System.out.println("1st number is less than or equal to 2nd number.");
  35. if(operand1 > operand2)
  36. System.out.println("1st number is greater than to 2nd number.");
  37. if(operand1 < operand2)
  38. System.out.println("1st number is less than to 2nd number.");
  39. if (operand1 != operand2)
  40. System.out.println("1st number and 2nd number are not equal.");
  41.  
  42. //Display the relationship of the operand 3 and operand 4
  43. if (operand3 == operand4)
  44. System.out.printf("\n3rd number and 4th number are equal.");
  45. if (operand3 >= operand4)
  46. System.out.printf("\n3rd number is greater than or equal to 4th number.");
  47. if(operand3 <= operand4)
  48. System.out.printf("\n3rd number is less than or equal to 4th number.");
  49. if(operand3 > operand4)
  50. System.out.printf("\n3rd number is greater than to 4th number.");
  51. if(operand3 < operand4)
  52. System.out.printf("\n3rd number is less than to 4th number.");
  53. if (operand3 != operand4)
  54. System.out.printf("\n3rd number and 4th number are not equal.");
  55. System.out.println("\n");
  56.  
  57. //Display the relationship of the operand 5 and operand 6
  58. if (operand5 == operand6)
  59. System.out.printf("\n5th number and 6th number are equal.");
  60. if (operand5 >= operand6)
  61. System.out.printf("\n5th number is greater than or equal to 6th number.");
  62. if(operand5 <= operand6)
  63. System.out.printf("\n5th number is less than or equal to 6th number.");
  64. if(operand5 > operand6)
  65. System.out.printf("\n5th number is greater than to 6th number.");
  66. if(operand5 < operand6)
  67. System.out.printf("\n5th number is less than to 6th number.");
  68. if (operand5 != operand6)
  69. System.out.printf("\n5th number and 6th number are not equal.");
  70. System.out.println("\n");
  71.  
  72. //Display the relationship of the operand 7 and operand 8
  73. if (operand7 == operand8)
  74. System.out.printf("\n7th number and 8th number are equal.");
  75. if (operand7 >= operand8)
  76. System.out.printf("\n7th number is greater than or equal to 8th number.");
  77. if(operand7 <= operand8)
  78. System.out.printf("\n7th number is less than or equal to 8th number.");
  79. if(operand7 > operand8)
  80. System.out.printf("\n7th number is greater than to 8th number.");
  81. if(operand7 < operand8)
  82. System.out.printf("\n7th number is less than to 8th number.");
  83. if (operand7 != operand8)
  84. System.out.printf("\n7th number and 8th number are not equal.");
  85. System.out.println("\n");
  86.  
  87. //Display the relationship of the operand 9 and operand 10
  88. if (operand9 == operand10)
  89. System.out.printf("\n9th number and 10th number are equal.");
  90. if (operand9 >= operand10)
  91. System.out.printf("\n9th number is greater than or equal to 10th number.");
  92. if(operand9 <= operand10)
  93. System.out.printf("\n9th number is less than or equal to 10th number.");
  94. if(operand9 > operand10)
  95. System.out.printf("\n9th number is greater than to 10th number.");
  96. if(operand9 < operand10)
  97. System.out.printf("\n9th number is less than to 10th number.");
  98. if (operand9 != operand10)
  99. System.out.printf("\n9th number and 10th number are not equal.");
  100. System.out.println("\n");
  101.  
  102. //Display the relationship of the operand 11 and operand 12
  103. if (operand11 == operand12)
  104. System.out.printf("\n11th number and 12th number are equal.");
  105. if (operand11 >= operand12)
  106. System.out.printf("\n11th number is greater than or equal to 12th number.");
  107. if(operand11 <= operand12)
  108. System.out.printf("\n11th number is less than or equal to 12th number.");
  109. if(operand11 > operand12)
  110. System.out.printf("\n11th number is greater than to 12th number.");
  111. if(operand11 < operand12)
  112. System.out.printf("\n11th number is less than to 12th number.");
  113. if (operand11 != operand12)
  114. System.out.printf("\n11th number and 12th number are not equal.");
  115.  
  116. }
  117.  
  118. }
  119.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement