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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started