Write a program in Java to find the square of a given number.
.5
5*5
Answers
Answered by
5
The códe:
import java.util.*;
class x{
public static void main(String s[]) {
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number: ");
int n=sc.nextInt();
System.out.println("Square: "+n*n);
sc.close();
}
}
Logic:
- Just accept the number and multiply it by itself and display it.
Similar questions