I have a program called public class ZeroCounter {. I want to add a new method to it called numberOfDigits() and add a line to test it in the main() method. How should I go abo
public class ZeroCounter {
public static void main(String[] args) {
System.out.println("Enter a nonnegative number:");
Scanner keyboard = new Scanner(System.in);
int number = keyboard.nextInt( ) ;
System.out.println(number + " contains " + numberOfZeros(number) + " zeros.");
} // End of main
private static int numberOfZeros(int number) {
int result = ///// calculation
return result;
}
}
You might want to read up a bit more on Java and how classes, methods and functions work first before going any further however.