Question
Step 1: design and code a program that uses a recursive method to convert a String of digit characters into an integer variable . For
Step 1: design and code a program that uses a recursive method to convert a String of digit characters into an integer variable. For example, convert the character string 13531 to an integer with the value 13,531. Note that the comma is present only to distinguish the integer value from the character string (in quotes) . The program should be repetitive to allow the user to enter any number of number strings, convert them, display them, and sum them.
When the user enters a sentinel value to terminate the input, display the sum and the calculated average of the numbers entered with one (1) decimal place.
To avoid the possibility of an overflow error, you may limit the String to eight (8) characters.
Step 2: design the recursive method to take in a number string as a parameter and return its integer value. The solution must be the result of the recursive process. It must NOT use an iterative process to obtain the return value. You are not allowed to use any method or function from the Java API or C++ STL. You must do the "parsing" in your own code in your own recursive method.
Remember, a recursive process obtains its results by calling itself repeatedly with differing values from the previous call. It ends (returns its result) when its input parameter detects the value of the base case. In this instance, the base case is when all the character digits have been converted.
There are two (2) methods that can easily be used in this process:
- One is by decreasing the power of ten multiple when moving from the leftmost character to the right.
- The other is to increase the sum by ten on each iteration before adding the current character (moving from left to right).
Step 3: Using the JAVADOC format, document the program and every method
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