2020-1-2 0:0:3 开始完成1月1日的任务,,不能断啊不能断;
mport java.util.Scanner; public class ComputeLoan { public static void main(String[] args){ Scanner input = new Scanner(System.in); System.out.println("Enter annual interest rate, e.g., 7.25%: "); double annualInterestRate = input.nextDouble(); double monthlyInterestRate = annualInterestRate / 1200; System.out.println("Enter number of years as an integer, e.g, 5: "); int numberOfYears = input.nextInt(); System.out.println("Enter loan amount, e.g., 120000.95: "); double loanAmount = input.nextDouble(); double monthlyPatment = loanAmount * monthlyInterestRate / (1- 1 / Math.pow(1 + monthlyInterestRate, numberOfYears * 12)); double totalPayment = monthlyPatment * numberOfYears * 12; System.out.println("The monthly payment is $" + (int)(monthlyPatment * 100) / 100.0); System.out.println("The total payment is $" + (int)(totalPayment * 100 ) / 100.0); } }
Math类是在java.lang包中,而java.lang包中的所有类是隐式被导入的,因此,不需要显式导入Math类。
0:25学完,学习时长22分钟