Using a loop, define function num7s(n) in Java, which takes an integer n and returns the number of 7s in the usual (base 10) representation of n. For example, num7s(2770) = 2 and num7s(99) = 0. Assume that the argument and answer both have type int.

(Hint. Successively divide the number by 10. Remember that k % 10 is the rightmost digit of k, and k/10 gives you the number that you get by removing the rightmost digit from k.)

 

    [Language: Java  Kind: function definition]