Needs help with JAVA code on this problem Any help would be
Needs help with JAVA code on this problem. Any help would be appreciated. Thanks!
Write an application to determine if the digits in a three-digit number are all odd, all even, or moxed odd and even. Your application should prompt the user to input a three-digit number. If the digits in the number all all odd, write \"This number contains all odd digits.\" If the digits are all even, write \"This number contains all even digits.\" If the number contains both odd and even digits, write \"This number contains both odd and even digits.\" Use integer division and modulus to access the digits in the number.
Solution
import java.util.Scanner;
public class Hello {
public static void main (String[] args)
{
int numodd=0, numeven=0, numzero=0;
int nMod = 0;
System.out.println(\"ENter three digit integer number::\");
Scanner scan = new Scanner(System.in);
int num = scan.nextInt();
String numS = Integer.toString(num);
int digits = numS.length();
while(num>0){
nMod=num%10;
if(nMod%2!=0)
numodd++;
else if(nMod==0)
numzero++;
else
numeven++;
num=num/10;
}
if(digits==numodd){
System.out.println(\"This number contains all odd digits\");
}else if(digits==numeven){
System.out.println(\"This number contains all even digits\");
}else{
System.out.println(\"This number contains both odd and even digits\");
}
}
}


