interest = balance * (annualInterestRate/1200)
Write a program that reads the balance and the annual percentage interest rate and displays the interest for the next month.Solution:
public static void main(String[] args) {
Scanner s = new Scanner(System.in);
double balance, annualInterestRate, interestRate;
System.out.print("Enter balance and interest rate (e.g., 3 for 3%):");
balance = s.nextDouble();
annualInterestRate = s.nextDouble();
interestRate = balance * (annualInterestRate / 1200);
System.out.print("The interest is " + interestRate);
}
No comments:
Post a Comment