Java program to find numerology number

Java program to find numerology number. Ram has found a new interest in numerology and has begun to pay attention to the numbers that appear in his daily routines. Make a program to assist him. The application should take the user’s input and show the digits one at a time, separated by a single space. Assume the value of the input is less than 500000. Display the sum of the digits, the numerology number, as well as the total amount of odd and even numbers.

import java.util.Scanner;
public class Main
{
public static void main (String[] args)
{
String str_num="";
int sum=0, even=0, odd=0, numerology=0, r=0;
Scanner sc= new Scanner(System.in);
System.out.println("Enter the number");
int num=sc.nextInt();
int temp=num;

while(temp>0)
{
r=temp%10;
str_num=(char)(r+'0')+" "+str_num;
sum+=r;
if(r%2==0)
{
even++;
}
else
{
odd++;
}
temp/=10;
}
numerology=sum;
Main obj=new Main();
while(numerology>9)
{
numerology=obj.numer(numerology);
}System.out.println("The Number is"+str_num);
System.out.println("Sum of digits"+sum);
System.out.println("Numerology number"+numerology);
System.out.println("Number of odd numbers"+odd);
System.out.println("Number of even numbers"+even);

}int numer(int a)
{
int ans=0, temp=a, r=0;
while(temp>0)
{
r=temp%10;
ans+=r;
temp/=10;
}
return ans;
}
}

 

Output:

Enter the number
4
The Number is4
Sum of digits4
Numerology number4
Number of odd numbers0
Number of even numbers1