In Java write a method that computes the balance of a bank a

In Java write a method that computes the balance of a bank account with a given initial balance and interest rate, after a given number of years. Assume interest is compounded yearly

Solution

//Write a method that computes the balance of a bank account with a given initial balance and interest rate, after a given number of years. Assume interest is compounded yearly

import java.util.Scanner;

public class CompoundInterest {

public static void main(String[] args) {

      Scanner input = new Scanner(System.in);

double principal = 0;

      double rate = 0;

      double time = 0;

double compoundInterest = 0;

double amount;

System.out.print(\"Enter the Principal amount : \");

      principal = input.nextDouble();

System.out.print(\"Enter the Rate of interest : \");

      rate = input.nextDouble();

System.out.print(\"Enter the Time : \");

      time = input.nextDouble();

compoundInterest = principal * Math.pow((1 + rate/100),time); // Compound interest calculation formula

amount = compoundInterest + principal;

System.out.println(\"The Compound Interest is : \"

     + compoundInterest);

System.out.println(\"The Total Amount in bank should be : \"

     + amount);

}

}

In Java write a method that computes the balance of a bank account with a given initial balance and interest rate, after a given number of years. Assume interes

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site