Question & Answer: 14. Compound Interest When a bank account pays compound interest, it pays interest not only on the princi amou…..

14. Compound Interest When a bank account pays compound interest, it pays interest not only on the princi amount that was deposited into the account, but also on the interest that has accumulate over time. Suppose you want to deposit some money into a savings account, and let the account earn compound interest for a certain number of years. The formula for calculating the balance of the account after a specified number of years is: pa The terms in the formula are: A is the amount of money in the account after the specified number of years. P is the principal amount that was originally deposited into the account r is the annual interest rate. n is the number of times per year that the interest is compounded. t is the specified number of years.
media%2Fcbf%2Fcbf617a3-de8a-4611-bb28-3b
media%2F1b8%2F1b8b4e69-9922-4ae8-984a-c4

14. Compound Interest When a bank account pays compound interest, it pays interest not only on the princi amount that was deposited into the account, but also on the interest that has accumulate over time. Suppose you want to deposit some money into a savings account, and let the account earn compound interest for a certain number of years. The formula for calculating the balance of the account after a specified number of years is: pa The terms in the formula are: A is the amount of money in the account after the specified number of years. P is the principal amount that was originally deposited into the account r is the annual interest rate. n is the number of times per year that the interest is compounded. t is the specified number of years.

Expert Answer

 

//Program 4: Distance Travelled

import java.util.Scanner;

public class DistanceTravelled {

/**

* @param args

*/

public static void main(String[] args) {

Scanner scanner = null;

try {

scanner = new Scanner(System.in);

// prompt to read distance

System.out.print(“What is the speed of the vehicle in mph? “);

int distance = scanner.nextInt();

// prompt to read hours

System.out.print(“How many hours has it traveled? “);

int hours = scanner.nextInt();

// initialize total distance to 0

int totalDistance = 0;

// print to the console

System.out.println(“HourtDistance Travelled”);

System.out.println(“________________________________”);

// repeat the loop until number of hours

for (int i = 1; i <= hours; i++) {

// add the distance

totalDistance += distance;

// print to the console

System.out.println(i + “t” + totalDistance);

}

} catch (Exception e) {

// TODO: handle exception

}

}

}

OUTPUT:

Still stressed from student homework?
Get quality assistance from academic writers!