Showing posts with label Perfect square. Show all posts
Showing posts with label Perfect square. Show all posts

Sunday, June 21, 2020

Write a program to input a number and check whether it is Perfect Square Number or not? (16, 25, 36…etc.)

22)  Write a program to input a number and check whether it is Perfect Square Number or    not? (16, 25, 36…etc.)

import java.util.*;
public class Perfect_Square_number_5
{
    public static void main(String args[ ])
    {
        Scanner sc = new Scanner (System.in);
        System.out.println("Enter a number");
        double a = sc.nextInt();
        double b = Math.sqrt(a);
        int c = (int)b;
        if(b==c)
        {
            System.out.println("Entered number is a PERFECT SQUARE number");
        }
        else
        {
             System.out.println("Entered number is not a PERFECT SQUARE number");
        } 
    }
}

 jhvghvgk ;nkjn ,nkjhj