Assignment
Input a number and display its even
digits only
(using until scanner) plzzzz it's urgent......
Answers
Answered by
2
Question:-
- Write a program to input a number and display it's even digits.
Program:-
import java.util.*;
class Digits
{
public static void main(String args[])
{
Scanner sc=new Scanner(System.in);
System.out.print("Enter a number: ");
int n=sc.nextInt();
System.out.print("Even digits are: ");
while(n!=0)
{
int d=n%10;
if(d%2==0)
System.out.print(d+" ");
n/=10;
}
}
}
Similar questions