Java use a for loop to determine the value of the deposit wi

Java use a for loop to determine the value of the deposit with the formula P=P+(P*(r/1200)

P=amount invested

r = interest rate

the result should look like if $10,000 invested and 5.75% for 3 months is used with no hard coding

Month 1: $10047.92

Month 2: $10096.06

Month 3 : $10144.44

Solution

DepositCheck.java

import java.text.DecimalFormat;


public class DepositCheck {

  
   public static void main(String[] args) {
       double deposit = 10000;
       double interest = 5.75;
       DecimalFormat df = new DecimalFormat(\"0.00\");
       for(int i=1;i<=3; i++){
           deposit = deposit + (deposit * ( interest/1200));
System.out.println(\"Month \"+i+\": $\"+df.format(deposit));

}
      
   }

}

Output:

Month 1: $10047.92
Month 2: $10096.06
Month 3: $10144.44

Java use a for loop to determine the value of the deposit with the formula P=P+(P*(r/1200) P=amount invested r = interest rate the result should look like if $1

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site