-8
このコードは機能しません。私は私が見えることはできません(日食で)次のエラーが解決してもらう:Javaのループの結果を出力
構文エラー、挿入、ReferenceExpression
構文エラーを完了するために、「:: IdentifierOrNew」を挿入します「;」
import java.util.Scanner;
public class DoWhile {
public static void main (String[] args)
{
Scanner in = new Scanner(System.in);
System.out.print("balance: ");
int balance = in.nextInt();
System.out.print("interestRate: ");
double interestRate = in.nextDouble();
System.out.print("year: ");
int year = in.nextInt();
System.out.print("input: ");
String input = in.next();
Integer interest = null; //to define interest
do
{
double interest = balance * interestRate/100;
balance += interest;
year++; // print current balance
}
while (input.equals("N"));
System.out.println("interest: " + interest + "balance: " + balance + "year: " + year) ;
};
}
:ここ
はあなたのコードを少しクリーンアップバージョンです。 – khelwood
'interest'は' Double'として定義されなければなりません: 'Double interest = null; do { interest = balance * interestRate/100; ' – DimaSan