Add more static methods to the Future Value application In this exercise, you'll add two more static
Question:
Add more static methods to the Future Value application In this exercise, you'll add two more static methods to the Future Value application that you saw at the end of this chapter. When you're done, the main) method should be even easier to read and understand.
Open and test the project
1. Open the project named ch05_exI_Future Value in the ex_starts directory.
2 Review the FutureValue App.java file, and notice how the code in the main) method calls the other methods in the file. Then, test the application to see how it works.
Add a method for displaying the results
3. Add a static method named printFormattedResults() anywhere in the file. This method should have private scope and a void return type, and it should accept the following parameters: a double named monthlylnvestment, a double named interestRate, an int named years, and a double named future Value
4. Move the code in the main) method that creates two NumberFormat objects, uses them to create a string, and then prints that string to the printFormattedFuture ValueResults (0 method.
5. Add code to the main) method that calls the printFormattedResults() method and passes it the values entered by the user, along with the value in the future Value variable. Then, test this enhancement to make sure the application still works properly.
Add a method for asking if the user wants to continue
6. Add another static method named askToContinue() anywhere in the file. This method should have public scope and a void return type, and it should accept a Scanner object named sc.
7. Move the code in the main) method that asks if the user wants to continue to the askToContinue() method. Then, adjust this code so it declares the choice variable as a String and so it returns the choice variable.
8. Add code to the main) method that passes the Scanner object to the askloContinue() method and stores the result in the choice variable. Then, test this enhancement to make sure the application still works properly.
Excellence in Business Communication
ISBN: 978-0136103769
9th edition
Authors: John V. Thill, Courtland L. Bovee