This is my assaigment:
Write a program that prompts the user for a beginning bank balance and an interest rate. The program will display the value of the account at the end of each year for 10 years. The output should show the value of the account for three different methods of compounding interest:
1) Annually: The interest is added once per year, at the end of the year. You can assume that the interest is posted exactly one year from the date of deposit.
2) Monthly: The interest is added once per month, at the end of the month. You can assume that interest is posted exactly one month after the date of deposit. Hint: Be sure to adjust the interest rate for the time period of the interest. If the rate is 5%, you must use (5/12)% in the monthly case.
3)Daily: The interest is added once per day, at the end of the day. You do not need to worry about leap years, assume that all years have 365 days. Hint: Be sure to adjust the interest rate for the time period of the interest. If the rate is 5%, you must use (5/365)% in the daily case.
Your program should allow the user to perform the calculation multiple times for different starting balances. A negative starting balance indicates that the user is done.
import java.util.Scanner;
import java.text.DecimalFormat;
public class TestBankInterest {
public static void main(String[] args) {
double balance, interest, newBalance;
Scanner keyboard = new Scanner(System.in);
DecimalFormat formatter = new DecimalFormat("#0.00");
System.out.println("What is your account's starting balance? ");
balance = keyboard.nextDouble();
System.out.println("What is the interest");
interest = keyboard.nextDouble();
for (int i = 0; i <= 12; i++) {
newBalance = balance + (interest / 100) * balance;
System.out.println("Month " + i + " = " + newBalance);
}
}
}
My problem is that I don't know how to figure out the formula for Annually, Yearly, or Daily for example;
newBalance = balance + (interest/100) * balance
Also, I'm confuss because I don't know if I should ask the user if they want to do it monthly or annually or daily
any help will be a biiiggggg help..
Thank You
Ps: I wants us to use loop ..in fact, 3 loops will be the answer for this