⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mortgage.java

📁 java核心技术卷一的源代码
💻 JAVA
字号:
/**
 * @version 1.10 10 Mar 1997 
 * @author Gary Cornell
 */

import corejava.*;
import java.text.*;

public class Mortgage
{  public static void main(String[] args)
   {  double principal;
      double yearlyInterest;
      int years;
 
      principal = Console.readDouble
         ("Loan amount (no commas):");
      yearlyInterest = Console.readDouble
         ("Interest rate in % (ex: use 7.5 for 7.5%):")/100; 
      years = Console.readInt("The number of years:");
         
      double monthlyInterest = yearlyInterest / 12;
      double payment = principal * monthlyInterest 
         / (1 - (Math.pow(1/(1 + monthlyInterest), 
            years * 12)));
      System.out.println("Your payment is ");
      NumberFormat nf = NumberFormat.getCurrencyInstance();
      System.out.println(nf.format(payment));
   }
}    

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -