Answered step by step
Verified Expert Solution
Question
1 Approved Answer
JAVA practice question! Write a main method that invokes each of these methods - use a variety of input to make sure you account for
JAVA practice question!
Write a main method that invokes each of these methods - use a variety of input to make sure you account for all conditions. 1. public static double investmentValue double amount, double interest, int numYears) Write a recursive method that takes as parameters an initial investment amount, an annual interest rate, and a number of years. The method should return the value of the investment after the given number of years, assuming that the interest is compounded annually. (For example, if the initial investment is 1000 and the interest rate is 10 percent, then after one year the investment will be worth 1100, after two years 1210, after three years 1331, etc) 2. public static String changePi(String str) Given a string, compute recursively (no loops) a new string where all appearances of "pi" have been replaced by "3.14". changePi("????") %2.14x" changePi("pipi") -> "3.143.14" changePi("pip") "3.14p" 3. sumDigits Method sumDigits takes a non-negative integer and returns the sum of its base- 10 digits. For example, sumDigits (1234) returns 12+3+ 4 10S. Note that it is easy to split an integer into two smaller pieces by dividing by 10 (e.g., 1234/10-123, and 1234 % 10 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