Computer Science, asked by areeza12, 10 months ago

WAP to input a number and check if it is a perfect number or not

Answers

Answered by nain31
10
 \bold{About \: Java}

Java is a machine independent language which can work on any platform. Its an object oriented programming which stress on object rather than data.

The main parts while doing Java programming are package, Class ,input variables, condition updating.

◼A perfect number is the number which Is square of other number .

Ex. 4=2×2

9=3×3

The following programming is done by io package of Java.

 \boxed{CODING}

import Java. io. *;

class check

{

public static void main(String args[])throws Exception

{

DataInputStream in = new DataInputStream(System.in);

int n, i , s=0;

System. out. println("Enter any number ");

n=Interger.parseInt(in.readLine());

s=Math.sqrt(n)

if((s*s)==n)

System. out. println("The number is perfect square ");

else

System. out. println("The number isn't perfect square ");

}

}
Similar questions