Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- package Test;
- import java.util.Scanner;
- public class evenNum {
- public static void main(String[] args) {
- // TODO Auto-generated method stub
- Scanner s = new Scanner(System.in);
- int location = 1, newNum = 0, x, temp;
- System.out.println("Enter a number with at least 5 digits? ");
- x = s.nextInt();
- temp = x;
- // for(int i=1; i <= newNum; i++){
- while (temp > 0) {
- temp = temp % 2;
- // if the number is divisible by 2 then it is even
- if (temp % 2 == 0) {
- newNum = temp * location;
- location = location * 10;
- temp = temp % 10;
- }
- x = x / 10;
- temp = x;
- }
- System.out.println("The number is : " + newNum);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement