Calculate the interest for the given base amount.
if year > 15 then calculate 12% else 10%.
Find the maturity amount
import java.util.Scanner;
public class App {
/**
* The start point of the program
*
* @param args
*/
public static void main(String[] args) {
float amount, rate=12, years, interest;
Scanner keyBoard = new Scanner(System.in);
System.out.print("Enter the amount: ");
amount = keyBoard.nextFloat();
System.out.print("Enter the time period (years): ");
years = keyBoard.nextFloat();
//if year > 15 then calculate 12% else 10%.
if(years<=15) {
rate =10;
}
keyBoard.close();
interest = (amount * rate * years) / 100;
System.out.print("Interest is: " + interest);
keyBoard.close();
}
}
Comments
Leave a comment