1 条题解
-
0
Java :
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner n = new Scanner(System.in); double a = n.nextDouble(); int y = n.nextInt(); double ir = n.nextDouble(); ir = ir / 12 / 100; double MP = (a * ir) / (1 - 1 / Math.pow(1 + ir, y * 12)); double MP1 = (int) (MP * 100) / 100.0; double TP = MP * 12 * y; double TP1 = (int) (TP * 100) / 100.0; System.out.println("Monthly Payment: " + MP1); System.out.println("Total Payment: " + TP1); System.out.println(); System.out.println("Payment#" + "\t" + "Interest" + "\t" + "Principal" + "\t" + "Balance"); for (int i = 1; i <= y * 12; i++) { double interest = (int) (ir * a * 100) / 100.0; double principal = (int) ((MP - interest) * 100) / 100.0; TP = (int) ((a - principal) * 100) / 100.0; a = TP; System.out.println(i + "\t\t" + interest + "\t\t" + principal + "\t\t" + TP); } } }
- 1
信息
- ID
- 3368
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- (无)
- 标签
- 递交数
- 0
- 已通过
- 0
- 上传者