皆さん、私はこのプログラムをコーディングしていますが、このエラーを引き起こす金利以外はすべて機能しています。
MenuDrivenProgram.java:92: possible loss of precision
found : double
required: int
deposit = balanceCurrent + interest;
^
1 error
ここに私のコードがあります、
public static void InvestmentReport()
{
System.out.printf("*** Investment Report stub ***\n");
// This is where your Part A solution goes
System.out.printf("*************** InvestmentReport Menu ***************\n\n");
Scanner console=new Scanner(System.in);
int deposit, monthly, interestRate;
double interest, balanceCurrent;
System.out.println ("Enter your initial deposit amount in dollars\n");
deposit = console.nextInt();
System.out.println ("Enter the annual interest rate as a percentage (eg. 6.0)\n");
interest = console.nextDouble();
System.out.println ("Enter your monthly deposit amount in dollars\n");
monthly = console.nextInt();
System.out.println ("Savings growth over the next 6 months:\n");
System.out.println ("Balance after first month: $" + deposit);
deposit = deposit + monthly;
System.out.println ("Interest earned for this month: $" + interest);
interest = balanceCurrent * interestRate / 12 / 100;
deposit = balanceCurrent + interest;
System.out.println ("Balance after second month: $" + deposit);
deposit = deposit + monthly;
System.out.println ("Interest earned for this month:\n");
System.out.println ("Balance after third month: $" + deposit);
deposit = deposit + monthly;
System.out.println ("Interest earned for this month:\n");
System.out.println ("Balance after fourth month: $" + deposit);
deposit = deposit + monthly;
System.out.println ("Interest earned for this month:\n");
System.out.println ("Balance after fifth month: $" + deposit);
deposit = deposit + monthly;
System.out.println ("Interest earned for this month:\n");
System.out.println ("Balance after sixth month: $" + deposit);
deposit = deposit + monthly;
System.out.println ("Interest earned for this month:\n");
}
私が間違っていたことと、それを修正する方法を教えてくれる人はいますか? 乾杯