Question: JAVA Part #1: Practice with Recursion Write a recursive method that calculates the sum of the digits in an integer. It should have this signature:

JAVA

Part #1: Practice with Recursion

Write a recursive method that calculates the sum of the digits in an integer. It should have this signature:

Public static int sumDigits(int n)

For example, sumDigits(234) returns 2 + 3 + 4 = 9. Use the main() method to ask the user to enter an integer and then call sumDigits(int).

Part #2: More Practice

Write a recursive method that calculates the number of uppercase letters in a string. The signature should be similar to part one:

Public static int countUpper(String strValue)

For example, countUpper(Hello World) returns 2. Use the main() method to ask the user to enter a string and then displays the number of capital letters in the string.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!