Command Line Argument Square: Write a program to accept a integer as command line argument and print the square of that integer.
Sample Input (Command Line Argument) 1:
10
Sample Output 1:
Square of the number :
100
Solution
class Main
{
public static void main(String jr[])
{
System.out.println("Square of the number :");
int a =Integer.parseInt(jr[0]);
System.out.println(a*a);
}
}
Happy Learning – If you require any further information, feel free to contact me.