Answer:
import java.util.Scanner;
public class Main
{
public static void main(String[] args) {
Scanner input = new Scanner(System.in);
double balance, rate, interest;
System.out.print("Enter the balance: ");
balance = input.nextDouble();
System.out.print("Enter the annual percentage interest rate [%4.25 must be entered as 4.25]: ");
rate = input.nextDouble();
if(balance < 0 || rate < 0)
System.out.println("The balance and/or interest rate cannot be negative!");
else{
interest = balance * (rate / 1200);
System.out.printf("The interest amount $%.2f", interest);
}
}
}
Explanation:
Ask the user to enter the balance
Ask the user to enter the interest rate as given format
Check the balance and rate. If any negative value is entered, print an error message. Otherwise, calculate the interest using the given formula and print the interest in required format