Write a Java program that accepts three numbers and check All numbers are equal or not


Introduction

In this demo I have used NetBeans IDE 8.2 for debugging purpose. But you can use any java programming language compiler as per your availability..


techstudy.org

Kindle Paperwhite High Resolution Display Tablet | Rs. 9999

  1.  
  2. import java.util.Scanner;
  3. public class JavaExcercise {
  4.  
  5. public static void main(String[] args)
  6. {
  7. Scanner in = new Scanner(System.in);
  8.  
  9. System.out.print("Enter first number: ");
  10. int num1 = in.nextInt();
  11. System.out.print("Enter second number: ");
  12. int num2 = in.nextInt();
  13. System.out.print("Enter third number: ");
  14. int num3 = in.nextInt();
  15.  
  16. if (num1 == num2 && num1 == num3)
  17. {
  18. System.out.println("All numbers are equal");
  19. }
  20. else if ((num1 == num2) || (num1 == num3) || (num3 == num2))
  21. {
  22. System.out.println("Neither all are equal or different");
  23. }
  24. else
  25. {
  26. System.out.println("All numbers are different");
  27. }
  28. }
  29. }

Result

java techstudy.org

     





Related Topics


Responses




Popular Posts

Facebook

Founded in 2016, Tech Study passionately delivers stylish and dynamic innovative information to programmer and technology lovers. http://www.techstudy.org/.