0

I need help with a lab I'm doing. In this lab you have to show the number of odd digits a number has, for example the number 4135 would have three odd digits. I've already done a lab where it tells you if a number is odd or even but I don't know how to change it and make it to do what it needs to.

This is my code for the odd or even lab:

```
/**
* It reads and number and determines if that number is even or add.
*/
import java.util.Scanner;
public class Odd_or_Even
{
public static void main(String [] args)
{
Scanner reader = new Scanner (System.in);
int answer;
System.out.print("Enter 1 to enter a number or 2 to quit -> ");
answer = reader.nextInt();
while (answer == 1)
{calculate();
System.out.print("Want to enter another number? Enter 1 for yes or 2 to quit -> ");
answer = reader.nextInt();
}
if (answer == 2)
System.out.println("Thanks for using this program");
else {
System.out.println("Error this number ("+answer+") is not an option try again.");
}
}
public static void calculate()
{
Scanner reader = new Scanner (System.in);
int num;
int finalresult;
System.out.print("Enter your number -> ");
num = reader.nextInt();
finalresult = num%2;
if (finalresult == 0)
System.out.println("Your number ("+num+") is an even number");
else
System.out.println("Your number("+num+") is and odd number");
}
```

*Edited 3 Years Ago by Nick Evan*: Fixed formatting