Respuesta :
Answer:
- init_balance = float(input("Initial balance: "))
- interest = float(input("Annual interest rate in percent: "))
- montly_interest = (interest / 100) / 12
- current_amount = init_balance + init_balance * montly_interest
- print("After first month: %.2f " % current_amount)
- current_amount = current_amount + current_amount * montly_interest
- print("After second month: %.2f " % current_amount)
- current_amount = current_amount + current_amount * montly_interest
- print("After third month: %.2f " % current_amount)
Explanation:
The solution code is written in Python.
Firstly, prompt user to input initial balance and annual interest rate using input function (Line 1 - 2).
Next, divide the annual interest by 100 and then by 12 to get the monthly interest rate (Line 4).
Apply the formula to calculate the current amount after adding the monthly interest (Line 5) and display the current month after first month (Line 6).
Repeat the same steps of Line 5 - 6 to calculate amount after two and three months and display print them to console. (Line 8 - 12).
Answer:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
System.out.print("Enter the initial balance: ");
double initialBalance = input.nextDouble();
System.out.print("Enter the annual interest rate: ");
double annualInterestRate = input.nextDouble();
double monthlyInterest = (annualInterestRate / 100) / 12;
double currentBalance = initialBalance + (initialBalance * monthlyInterest);
for(int month=1; month<=3; month++){
System.out.printf("Your balance after " + month + ". month: %.2f \n", ((initialBalance + (initialBalance * monthlyInterest)* month)));
}
}
}
Explanation:
* The code is written in Java
- Ask user to enter initial balance and annual interest rate
- Calculate the monthly interest
- Calculate the current balance
- Print the value of the balance after first three months using for loop