package methods;
import java.util.Scanner;
/**
*
* @author Billy
*/
public class Methods {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
double Loanamount; // Loan amount from user
double Aintrate; // User's annual interest rate
double months; // Number of months on loan
double monp; // Monthly payment
double Mintrate; // Monthly interest rate
double n; // The number of payments
// declare an instance of Scanner to read the datastream from the keyboard.
Scanner kb = new Scanner(System.in);
// Get user's loan amount
System.out.print("Please enter your total loan amount: ");
Loanamount = kb.nextDouble();
// Get user's interest rate
System.out.print("Please enter your annual interest rate as a decimal: ");
Aintrate = kb.nextDouble();
// Get user's number of months
System.out.print("Please enter the number of months left on your loan: ");
months = kb.nextDouble();
// Calculate montly interest rate
Mintrate = ((Aintrate/12));
System.out.println("Your monthly interest rate is " + " " + Mintrate);
// Calculate number of payments
n = ((months * 12));
// Calculate monthly payment
我的下一个工作是找出每月付款使用这个公式。努布需要一些帮助实施一个公式
M = P [I(1 + I)^ N]/[(1 + I)^ N - 1]
凡
M =每月按揭付款
P =借用(Loanamount)的量
I =每月利率(Mintrate)
N =支付次数
我尝试以下,但我只是不能想出办法来
使用'Math.pow',这就是你正在寻找的,而不是''''','''''''''''''','''''''''''''',''''''''''''','''''',''''''''''''''''''''''''''''''''',''''''''''''''''',''''''''''''''''''''''''''''还有,你的代码应该包括这个形式, – SomeJavaGuy
如果使用'double'类型仍然足以进行估计,则由于舍入误差,它不应该用于财务计算。 –