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

📄 finderrors.java

📁 《A first book of java》by Gary J.Bronson 北大出版社
💻 JAVA
字号:
import javax.swing.*;
import java.text.*;  // needed for formatting
public class FindErrors
{
  public static void main(String[] args)
  {
    String s1, outMessage;
    double capital, amount, rate, nyrs;
    DecimalFormat num = new DecimalFormat(",###.00");
    
    outMessage = "This program calculates the amount of money\n" 
               + "in a bank account for an initial deposit\n" 
               + "invested for n years at an interest rate r.";
   
    JOptionPane.showMessageDialog(null, outMessage, 
                                 "Program 4.7", 
                                 JOptionPane.INFORMATION_MESSAGE);
    s1 = JOptionPane.showInputDialog("Enter the initial amount in the account:");
    amount = Double.parseDouble(s1);
    s1 = JOptionPane.showInputDialog("Enter the number of years:");
    nyrs = Double.parseDouble(s1);
    capital = amount * Math.pow((1 + rate/100.0), nyrs);
    outMessage = "The final amount of money is $" +num.format(capital);
      
    JOptionPane.showMessageDialog(null, outMessage, 
                    "Program 4-7", 
                    JOptionPane.INFORMATION_MESSAGE);
   
    System.exit(0);  
  }
}

⌨️ 快捷键说明

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