|
|
|
Here's alittle tool for calculatiang your Monthly
bank balance. The program takes in values for the amount that is deposited every month, the interest rate and the amount
of months you wanna make the calculation for.
//Name of Program File: MonthlyBankBalance.java
//Author: Travis McGrath
//INFO140 Section # 04 Date: Oct. 13, 2001
//Your Company Name: Myself
//Description: This program will calculate the growth of a savings count
// at a bank for how many months the user enters.
public class MonthlyBankBalance
{
public static void main (String[]args)
{
//explain program to user
System.out.print("This program will calculate the growth of a savings count" +
" at a bank.");
System.out.println("");
//get fixed amount of money deposited each month from user
System.out.print("Please enter the amount of money deposited each month: ");
double monthlyDeposit = MyInput.readDouble();
System.out.println("");
//get monthly interest rate as a percent.
System.out.print("Please enter the monthly interest rate as a percent. " +
"For example 5.5: ");
double monthlyInterestRate = MyInput.readDouble();
System.out.println("");
//get the number of months to perform the calculation for
System.out.print("Please enter the number of months for calculation: ");
int numberOfMonths = MyInput.readInt();
System.out.println("");
//declare some variables for while loop
double balance = 0;
int i = 1;
while (i <= numberOfMonths)
{
//calculate monthly balance
balance = balance * (1 + monthlyInterestRate/100)
+ monthlyDeposit;
//display results
System.out.println("The balance is " + balance + " after month " + i++);
}//end while loop
}//end main
}//end class
|