/**
* 财务应用程序:计算利息。
* 读取收支余额和年百分率(yearRate),显示两个版本下月利息。
* 利息额(interest) = 收支余额(balance) * (年利率 / 1200)。
* 下面是一个运行示例:
* ——————————————————————————————————————————————————————————————
* | Enter balance and interest rate (e.g., 3 for 3%): 1000 3.5 |
* | The interest is 2.91667 |
* ——————————————————————————————————————————————————————————————
*/
package Test;
import javax.swing.JOptionPane;
public class T212InputDialog {
public static void main(String[] args) {
String balanceString = JOptionPane.showInputDialog("Enter balance and interest rate (e.g., 3 for 3%): ");
double balance = Double.parseDouble(balanceString);
String yearRateString = JOptionPane.showInputDialog("Enter balance and interest rate (e.g., 3 for 3%): ");
double yearRate = Double.parseDouble(yearRateString);
double interest = balance * (yearRate / 1200);
String ouput = "The interest is " + interest;
JOptionPane.showMessageDialog(null, ouput);
}
}
第2章:财务应用程序:计算利息 【对话框输出】
最新推荐文章于 2012-12-25 11:56:57 发布