私はエラーがあり、私のJavaプロジェクトのためにそれを修正する方法を知りたいと思っていました。私はこれらのように出てまったく同じにする必要がありDecimalFormat.formatメソッド呼び出し:互換性のない型
:
- 小数としてあなたの年利は何ですか? (例:0.045):.033
- あなたの住宅ローンは何年保持されますか? 15
- あなたが借りた住宅ローンの金額は? 300000
- 数0.033は、住宅ローンの金額はドルで$ 300,000.00
- 毎月の支払いは$ 2,115.30
- ですドルで年間での総支払は$ 380,754.76
- 以上である3.3%
- のように表すことができます。 - 支払は$ 80,754.76である上、支払 の割合としての住宅ローンは26.9
であり、これは、私は、Eclipse上で何をしたかです。
double annIntRat;
int nOY;
int borrowMor;
int M;
double monthPay;
double mIR;
Scanner scnr = new Scanner(System.in);
// Your code should go below this line
System.out.print("What is your annual interest rate as a decimal? (ex 0.045): ");
annIntRat = scnr.nextDouble();
System.out.print("How many years will your mortgage be held? ");
nOY = scnr.nextInt();
System.out.print("What amount of the mortgage did you borrow? ");
borrowMor = scnr.nextInt();
DecimalFormat df = new DecimalFormat("0.0");
System.out.println("\nThe number "+annIntRat+" can be represented as "+df.format((annIntRat)*100)+"%");
NumberFormat defaultFormat = NumberFormat.getCurrencyInstance();
M=defaultFormat.format(borrowMor); //< Here is the error and tells me to change to String.But if I do so, there will be an error down there for monthPay=.....
System.out.println("The mortgage amount is "+M);
mIR=(annIntRat)/12;
monthPay=(mIR * M)/(1-(1/Math.pow(1+mIR,12*nOY)));
あなたは問題が何であるかを指摘していただけますか? –
"M = defaultFormat.format(borrowMor)"の隣に1つあります。 –