Question: This is in Java being run through eclipse /** * Determine if a given positive integer has a 5 in the second rightmost digit *
This is in Java being run through eclipse
/** * Determine if a given positive integer has a 5 in the second rightmost digit * * For example: * * 5 returns false * 52 returns true * 151 returns true * 30050 returns true * 5000 returns false * * Hint: you'll want to use the modulus operator % and the division operation / * See section 4.2.3 for details. Don't convert the number to a string! * * Bonus Hint: you usually should not use an if statement to return a boolean * * if (x % 2 == 0) { // checks if x is even * return true; * } else { * return false; * } * * Instead, just return the result of the boolean test directly * * return x % 2 == 0; //returns true or false * * @param input * @return */ public static boolean secondDigit5(int input) { return false; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
