Saved Bookmarks
| 1. |
M T W T F SPage No:YOUVADate:9 Write a Program in java to input a no and checkweather it is aperfect square or not. |
Answer» Answer:The given program is written in Java. import java.util.*; public class IsPerfectSquare { public static void main(String ARGS[]) { Scanner sc=new Scanner(System.in); int N; double s; System.out.print("Enter a number: "); n=sc.nextInt(); s=Math.sqrt(n); if(s*s==n) System.out.println("Perfect SQUARE."); else System.out.println("Not a perfect square."); sc.close(); } } Variable Descriptions:Explanation:
See the attachments. |
|