Online Course Discussion Forum
APCSA Hw06 Q23 Age Converter Errors
Regarding the Scanner: it should run after you add "System.in" as parameter. I am not sure why it doesn't take your input, but maybe it is the following error that prevents your code from being compiled, so you are not at the step of typing input yet.
The "convertToHumanAge" method is an instance method, (not static), so it cannot be called this way from the "main" method. "main" should be considered an outside method, because it is where the system starts your program, and you must instantiate this class to run the "convertToHumanAge" method. Here is how you should do it:
After the "int humanYear=sc.nextInt();" line, add the following line: (btw, isn't this supposed to be named "dogYear"?)
hw06q23 hw = new hw06q23();
Then, call the method this way:
int answer = hw.convertToHumanAge(humanYear);
Please let me know if it works. Also, as good style, the class name is supposed to start with a capital letter.
Social networks