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'類型仍然足以進行估計,則由於舍入誤差,它不應該用於財務計算。 –