I'm starting to study Java now by the book "Java as Programming 10 Ed" and I'm having a hard time compiling this book code in Eclipse.
Follow the code below
Could anyone tell me how to make this code compile?
Note: JDK 9, Java 9, Eclipse Oxygen 4.7.2
publicclassAccount{privateStringname;privatedoublebalance;publicAccount(Stringname,doublebalance){this.name=name;if(balance>0.0)this.balance=balance;}//Fimmetodopublicvoiddeposit(doubledepositAmount){if(depositAmount>0.0)balance=balance+depositAmount;}//fimmetod0publicdoublegetBalance(){returnbalance;}//fimgetpublicvoidsetName(Stringname){this.name=name;}//fimsetpublicStringgetName(){returnname;}//fimget}publicclassAccountTest{publicstaticvoidmain(String[]args){//CriaosobjetoseatribuiargumentosparaocosntrutorAccountaccount1=newAccount("Jane Gree", 50.00);
Account account2 = new Account("John Blue", -7.53);
// Exibe o saldo inicial
System.out.printf("% balance: $%.2f %n", account1.getName(), account1.getBalance());
System.out.printf("% balance: $%.2f %n%n", account2.getName(), account2.getBalance());
Scanner input = new Scanner (System.in);
// Obtendo a entrada na conta 1
System.out.print("Enter deposit amount for account1: ");
double depositAmount = input.nextDouble();
System.out.printf("%n adding %.2f to account1 balance %n%n", depositAmount);
account1.deposit(depositAmount);
// exibe os saldos
System.out.printf("%s balance: $%.2 %n", account1.getName(), account1.getBalance());
System.out.printf("%s balance: $%.2 %n%n", account2.getName(), account2.getBalance());
// Obtendo a entrada na conta 2
System.out.print("Enter deposit amount for account2: ");
depositAmount = input.nextDouble();
System.out.printf("%nadding %.2f to account2 balance %n%n", depositAmount);
account2.deposit(depositAmount);
// exibe os saldos
System.out.printf("%s balance: $%.2 %n", account1.getName(), account1.getBalance());
System.out.printf("%s balance: $%.2 %n%n", account2.getName(), account2.getBalance());
input.close();
}
}