Well i got it working today..tell me what you guyz think
Code:
package assignment2;
/**
* <p>Title: Assignment 2</p>
* <p>Description: CS 161 Assignment 2 </p>
* <p>Copyright: Copyright (c) 2004</p>
* <p>Company: UW-River Falls</p>
* @author Eric Merker
* @email ericmerker@centurytel.net
* @date October 4th 2004
* @team prometheusfree.org crew visit us at irc.shadowfire.org at #prometheus and the tfproject.org crew at #tfp
* @version 1.0
*/
//This package is for the Decimal Format String
import java.text.*;
// This package is used for the IOException class and the Buffered Reader
import java.io.*;
import java.text.DecimalFormat;
public class Assignment2 {
public Assignment2() {
}
//The IOException makes it so it ignore Input Output errors
public static void main(String[] args)throws IOException {
Assignment2 assignment21 = new Assignment2();
//These three lines are the values that need to be input and tells what type of variables they are
String inputStr;
int N;
double P, R;
//The BufferedReader is used to help input the variables
BufferedReader bufReader;
bufReader = new BufferedReader( new InputStreamReader ( System.in ) );
//this takes input from the users keyboard and places into the formula for each of the variables
System.out.print(" Input Percent Interest Compounded Anually: ");
inputStr = bufReader.readLine();
R = Double.parseDouble(inputStr);
System.out.print(" Number of Years: ");
inputStr = bufReader.readLine();
//This is an Int instead of a double is why the the following code is written
N = Integer.parseInt(inputStr);
System.out.print(" Input Number of dollars you wish to invest: ");
inputStr = bufReader.readLine();
P = Double.parseDouble(inputStr);
// This is the actual math formula, the word double is in front to tell the program what the value actually are
double denominator = ( 1 - R/100);
double numerator = P*(1-(Math.pow(R/100, N+1)));
double total = numerator / denominator;
//This makes it so any double number will only be out the 0.00 spot.
DecimalFormat df = new DecimalFormat ( "0.00" );
//This will say the final value as an result of the formula above the df.format makes the out only say the value to the 0.00 spot
System.out.println( "Your money will accrue to $" + df.format(total) );
}
}