exercise_1_2
2010-08-05 14:33
260 查看
package y2kmz.com.daikuan;//说明程序出现的类在该包中 import javax.swing.JOptionPane;//导入javax.swing这个包中的JOptionPane这个类 public class exercise_1_2 {//公共类exercise public static void main(String[] args) { // Enter yearly interest rate String annualIntrestRateString = JOptionPane.showInputDialog( "输入利率,如 8.11:");//输入String类型的变量annuealInterstRateString(年利率) // Convert string to double double annualInterestRate = Double.parseDouble(annualIntrestRateString);//annualInterestRate,利率 //将String类型变量annualInterestRate转换为Double型变量() // Obtain monthly interest rate double monthlyInterestRate = annualInterestRate/1200; //月利率等于年利率除以1200 // Enter number of years String numOfYearsString = JOptionPane.showInputDialog( "输入贷款年限, /n如 5:");//贷款年限,numOfYearsString //输入String类型的numOfYearsString(贷款年限) // Convert string to int int numOfYears = Integer.parseInt(numOfYearsString); //将String类型变量numOfYears转换成Int类型 String investmentAmountString = JOptionPane.showInputDialog( "输入贷款总额, 如 120000.00:");//investmentAmountString,贷款总额 //输入String类型变量investmentString(贷款总量) // Convert string to double double investmentAmount = Double.parseDouble(investmentAmountString); //将字符串类型的贷款总量转换成双精度浮点型 double futureValue = (investmentAmount * monthlyInterestRate) /(1-1/Math.pow((1+monthlyInterestRate),(numOfYears*12))); //double类型futureValue=****** JOptionPane.showMessageDialog(new JOptionPane(), "月偿还金额:"+((int)(futureValue * 100) / 100.0)+" 总偿还金额:"+((int)(futureValue * 12 * numOfYears * 100) / 100.0)); //输出 System.exit(0);//程序结束 } }
相关文章推荐
- Selected solutions to exercise of "The C Programming Language" 2e (Part 6)
- Think in java 答案_Chapter 2_Exercise 8
- Think in java 答案_Chapter 4_Exercise 2
- Think in java 答案_Chapter 4_Exercise 18
- Think in java 答案_Chapter 5_Exercise 12
- 卡内基SSD6 System-Level Programming Exercise 1总结
- icarnegie网站测试题(exercise 1)答案
- MVC exercise project
- 算法导论 Exercise 4.2-2
- SICP Exercise 3.51
- SICP Exercise 4.9
- google code jam exercise——T9 Spelling
- google code jam exercise——Rotate
- SICP Exercise 4.13
- APUE2e之Exercise 10.11
- Analysis by Its History_exercise 1.5
- A Tour of Go: Exercise: Rot13 Reader
- Solution for Introduction to Algorithms (3rd Edition) Exercise 26.4-2
- Exercise 5: Regularization
- C程序设计语言 Exercise 2-9