Computer Science, asked by mishrakaruna602, 12 hours ago

write a Java programming to print all even numbers between m and n where m>n if m<n ?​

Answers

Answered by ParikshitPulliwar
1

Answer: import java.util.Scanner;

public class KboatPerfectSquare

{

   public static void main(String args[]) {

       Scanner in = new Scanner(System.in);

       System.out.print("Enter m: ");

       int m = in.nextInt();

       System.out.print("Enter n: ");

       int n = in.nextInt();

       

       if (m < n && m > 0 && n > 0) {

           for (int i = m; i <= n; i++) {

               System.out.println("Number = " + i);

               double sroot = Math.sqrt(i);

               if (sroot == Math.floor(sroot))

                   System.out.println(i + " is a perfect square");    

           }

       }

       else {

           System.out.println("Invalid input");

       }

   }

}

Explanation:

Similar questions