I am taking a java class this semester and to me its pretty challenging because we are going really fast. I have a project that is due very soon so I am in need of some help. I think I have the majority of it completed I just think I need help on part 4 and mostly part 5. This part is the newest information that we learned, so I am not too familiar with it. I copy and pasted the word file of the project assignment and I also attached a .txt file of what I currently have. Any advice or help you can provide would be greatly appreciated. I feel lost, and for that matter, frustrated. Thanks in advance for any help you are willing to provide.
AnnuityValue.txt
__________________________________________________ ____________________________________
Project 1
Due date: September 28, 2009
1. Project description: You are asked to develop a program to compute the amount of money (V) needed to be deposited into a student’s money market account so that he/she can withdraw a fixed amount (P) every month for the next (n) months. This money market account will pay him/her interest of (i)% per annum each month. The amount V is computed as follows:
// it wouldn't let me copy and paste the math problem, but my professor says this part is fine so ill post the code for it
deposit = withdrawal*((1-Math.pow(1+(interest/12),-months))/(interest/12));
Please following the steps below to complete this assignment.
1. Open TextPad, and type this code:
import javax.swing.*;
import java.text.*;
public class AnnuityValue {
public static void main(String[] args) {
// Please insert your Java code here
System.exit (0);
}
}
Save this code as AnnuityValue.java.
2. Modify this code to insert the followings:
- Declare 4 variables: one variable to represent the amount of money to be deposited, one variable represents the annual interest rate and one variable represents and number of months, and one variable represents the amount of money to be withdrawn. We use “double” data type to represent the amount of money to be deposited, annual interest rate and the amount of money to be withdrawn. We use “int” data type to represent the number of months.
- Print out the following description on the screen using System.out.println:
“This program computes the amount of money (V) needed to be deposited into a student’s money market account so that he/she can withdraw a fixed amount (P) every month for the next (n) months. This money market account will pay him/her interest of (i)% per annum each month”
Save the update of this file to AnnuityValue.java. Compile and run this code. You should see the description displayed on the screen.
3. Modify this code to use JOptionPane as shown in our class to get input values from users. You should prompt a user to enter annual interest rate, and store it to the variable that represents the annual interest rate (which is declared in step 2). You should prompt a user to enter the amount of money to be withdrawn and store it to the corresponding variable declared in step 2. Finally, you prompt a user to enter the number of months and store it to the variable that represents the number of months in step 2. Notice that you should use a temporary String as a place holder first and then convert from String to integer or double correspondingly. After you modify the code, save, compile and run this code. (30 points)
4. Please use the formula (1) above compute the amount of money to be deposited. Save, compile and run this code
5. Modify the program in step 4 to make sure that the input values are valid. In this case, please check if the annual interest rate is from 0.08% to 0.5%, the number of years is greater than zero, and the amount of money to be withdrawn is greater than zero. Use if statement for this task. Print out the error messages if these values are invalid and exit the program.
Save, compile, run and submit this code.