increasingDigits
Category: Programming
Author: Stuart Reges
Book Chapter: 5.3
Problem: increasingDigits
Write a method called increasingDigits that takes an integer n as a parameter and that returns true if the digits of n are strictly increasing and that returns false otherwise. In other words, your method should determine if the first digit of the number is strictly less than the second digit, and the second digit is strictly less than the third digit, and the third digit is strictly less than the fourth digit, and so on. Your method should return true for a one-digit number. The table below shows sample calls and the value that should be returned. Method Value Method Value Call Returned Call Returned --------------------------------- --------------------------------- increasingDigits(0) true increasingDigits(8) true increasingDigits(18) true increasingDigits(25) true increasingDigits(39) true increasingDigits(357) true increasingDigits(1247) true increasingDigits(456789) true increasingDigits(42) false increasingDigits(33) false increasingDigits(1232) false increasingDigits(354) false increasingDigits(543) false increasingDigits(37789) false You may not use a String or other object to solve this problem. You may assume that the number passed to your method is not negative, but it might be 0.