初学Java 使用输入对话框
2024-09-25 02:13:54
import javax.swing.JOptionPane;
public class ComputeLoanUsingInputDialog {
public static void main(String[] args) {
String annualInterestRateString = JOptionPane.showInputDialog(
"Enter yearly interest rate, for example 8.25:"); double annualInterestRate =
Double.parseDouble(annualInterestRateString);
double monthlyInteresRate = annualInterestRate / ;
String numberOfYearsString = JOptionPane.showInputDialog(
"Enter number of years as an integer, \nfor example 5:"); int numberOfYears = Integer.parseInt(numberOfYearsString);
String loanString = JOptionPane.showInputDialog(
"Enter loan amount, for example 120000.95:"); double loanAmount = Double.parseDouble(loanString); double monthlyPayment = loanAmount * monthlyInteresRate / (
- / Math.pow( + monthlyInteresRate, numberOfYears * ));
double totalPayment = monthlyPayment * numberOfYears * ; monthlyPayment = (int)(monthlyPayment * ) / 100.0;
totalPayment = (int)(totalPayment * ) / 100.0; String output = "the monthly payment is " + monthlyPayment +
"\nthe total payment is " + totalPayment;
JOptionPane.showMessageDialog(null, output); }
}
最新文章
- jQuery MiniUI开发系列之:使用API文档
- Asp.Net MVC4入门指南(6):验证编辑方法和编辑视图
- css3易混淆属性详解
- MyEclipse从数据库反向生成实体类之Hibernate方式 反向工程
- Jsp页显示时间标签JSTL标签 <;fmt:formatDate/>; 实例大全
- git流程及操作
- phalcon:非空字段不能在beforeCreate赋值,可以改用beforeValidationOnCreate
- 从cpu加电到加载OS内核的详细过程(清华大学ucore-lab1总结一)
- ASP.NET页面同时发起多个ajax请求,出现阻塞情况
- ORA-01034/ORA-27101解决
- 淘特房产CMS系统 7.5
- html5 画个圈
- OpenCv的Java,C++开发环境配置
- mysql 日期 字符串
- 强大的css3库
- SVG之颜色、渐变和笔刷的使用
- Typora开启行内公式
- oracle数据库连接 ORA-12638:身份证明检索失败
- 关于JAVA文件的字节转字符练习
- c#运用反射获取属性和设置属性值
热门文章
- Cobaltstrike系列教程(二)-Listner与Payload生成 heatlevel
- Anacond的介绍
- 在linux中 部署 mongo 数据库服务端
- 【Swagger2】SpringBoot整合swagger2
- File upload with cropping support using Cropper --jquery file upload
- MATLAB 用 imresize() 函数缩小图象是 double 和 uint8 有差别
- day15—jQuery UI之widgets插件
- CentOS7.X安装FastDFS-5.10
- delphi 手势 识别 哈哈
- Vagrant 入门 - 同步目录(synced folders)