Reference no: EM13850765
Problem Description
This lab assignment is to improve the solution of computing the monthly saving problem in Lab Assignment 3 by using a loop to eliminate the repeated calculations. That is, all the requirements of Lab 3 remain the same, but the solution to the problem is changed.
Assignment Requirements
The requirements of Lab 3 remain the same except the following changes:
1) Modify the flowchart diagram for Lab 3 assignment to reflect the change of the solution, i.e., the use of a loop to replace the repeated calculations.
2) Modify the pseudo-code in Lab 3 Assignment, accordingly.
3) Continue to use the JOptionPane class for all input and output, instead of the Scanner object.
4) Perform all input data error checking as required in Lab 3.
(The above requirements are also applicable to the bonus problem.)
The following three test runs in Lab Assignment 3 should be rerun to confirm the program produces the correct answers:
|
Saving Amount
|
Annual Interest Rate
|
Compound Value after 6th Month
|
Test run 1
|
100
|
5.0
|
608.81
|
Test run 2
|
150
|
5.0
|
913.22
|
Test run 3
|
100
|
5.5
|
609.70
|
When the monthly saving amount or the annual interest rate or both are not positive, your program should display informative error messages. Your test case should include the following three possible casesIt is your choice of the test data covering those three test cases listed above.
Saving Amount
|
Annual Interest Rate
|
Positive
|
Not positive
|
Not positive
|
Positive
|
Not positive
|
Not positive
|
Submission Requirements
Your assignment submission should be prepared as follows:
1) The flowchart diagram document
2) The Java source code file (i.e., *.java file) you write for this assignment
3) The MS Word document containing the screen captures of all test cases you run, making sure the screens show the input and output. To receive the credit for completing testing, your screen captures should include all test cases as specified above.
Submit all files above into the dropbox of this assignment.
(Bonus Problem:
Enhance the function of the application to allow the user to compare the compound values of different annual interest rates. The user enters the monthly saving amount and an annual interest rate. The program computes the compound value after month 6 and display the result.
The program then asks if the user wants to compute the compound value of a different rate using the Java confirmation dialog box. If the user clicks the Yes button, the program should then prompt the user to enter a new set of data and repeat the same calculation. If the user clicks the No button, the program would then end. The user should be able to try several different rates.
Successful completion of this task will add 25 points to the assignment.)
Assignment Assessment
The assessment rubric for the assignment is below:
Task Items
|
Complete & Correct
|
Incomplete/ Partially Correct
|
Missing
|
Solution Design (flowchart diagram) (15%)
|
100%
|
By %
|
0
|
Solution Pseudo-Code (Java comments) (10%)
|
100%
|
By %
|
0
|
Java Program (60%)
|
100%
|
By %
|
0
|
Testing Completeness (15%)
|
100%
|
By %
|
0
|
Problem Description
The calculation of the compound value we have done in the last three assignments is a very common financial calculation in many financial applications. For example, producing the monthly account statements requires calculating the compound value of bank accounts. Thus, making the calculation readily available to financial applications can reduce the development effort and improve the quality of those applications.
Java methods allow us to package such financial calculations into reusable methods so that they are ready to be invoked by financial applications. This lab assignment is to improve the solution of computing the monthly saving problem in Lab Assignment 4 by extracting the calculation of the compound value into a separate method. The main learning objective is to understand method definition, parameter passing, and method invocation.
Assignment Requirements
Create a new method to calculate the compound value of monthly savings. The requirements of the new method are described below:
1) The modifiers of the method should be public static so that it can be called by the main method
2) The method should return the calculated compound value and the return value type of the method is of double type
3) The name of the method is your choice but should be descriptive and follow the Java naming convention.
4) The parameter list of the method should consist of the following three parameters:
a. The amount of monthly saving (double type)
b. The annual interest rate (double type)
c. The number of months (int type) of the compound value
5) The method should perform the following tasks:
a. Validate each parameter. If a parameter is not positive, display an error message and terminate the method by returning a negative compound value to signal that the calculation failed. Note that it takes only one data error to terminate the calculation.
b. If all parameters are positive, use a loop to calculate the compound value same as you did in Lab Assignment 4. The number of months to repeat is determined by the number of months parameter passed into the method.
c. After the calculation is completed, return the compound value after the given number of months.
The main method is now simplified to do only the following tasks:
1) Prompt the user to input the data and read the data entered by the user.
2) Call the new method to calculate the compound value by passing the monthly saving, annual interest rate, and the number of months as arguments and save the compound value returned by the method
3) If the compound value returned by the method call is positive, display the compound value. Otherwise, simply end the execution of the main method because the error message has already been reported in the method.
Because of the above changes, the flowchart diagram of Lab Assignment 4 should be modified to reflect the changes taken place in your program. If you did the bonus problem in Lab Assignment 4, you may use either your bonus solution or the regular solution as the base for this assignment
The requirement of using GUI dialog boxes for all input and output remains unchanged.
You should run the same number of test cases as required in Lab Assignment 4.
Bonus: 10% of your total score on this assignment will be added to your assignment grade
Submission Requirements
Your assignment submission should include the following items:
1) The modified flowchart diagram
2) The Java source code file (i.e., *.java file)
3) The screen captures of all test cases you run; only the dialog boxes need to be captured.
Submit all those files above into the dropbox of this assignment.
Assignment Assessment
The assessment rubric for the assignment is below:
Task Items
|
Complete & Correct
|
Incomplete/ Partially Correct
|
Missing
|
Solution Design (flowchart diagram) (15%)
|
100%
|
By %
|
0
|
Solution Pseudo-Code (Java comments) (10%)
|
100%
|
By %
|
0
|
Java Program (60%)
|
100%
|
By %
|
0
|
Testing Completeness (15%)
|
100%
|
By %
|
0
|