Input any number and print the square of all even digit in Java
Answers
Answered by
1
Answer:
Program:-
import java.util.*;
public class Main
{
public static void main(String args[])
{
Scanner in=new Scanner(System.in);
int n,a;
System.out.println("Enter a number");
n=in.nextInt();
while(n!=0)
{
a=n%10;
if(a%2==0)
System.out.println("The square of " +a+ "="+(a*a));
n=n/10;
}
}
}
See the attachment for output
Attachments:
Similar questions