Using java write a program to input a number and print its square and cube.
Answers
Answered by
3
Again scanner class has been used
import java.util.Scanner;
public class SquareDigit
{
public static void main (String[] args)
{
int no,m,s;
Scanner input = new Scanner(System.in);
System.out.println("Enter Number :");
no = input.nextInt();
while(no>0)
{
m=no%10;
s = m*m;
System.out.println("Square of "+m+" is "+s);
no=no/10;
}
}
}
Similar questions