I try to this solve this question and I have some problem.Can you please tell where the wrong and explan to me.
package bank;
public class BankAccount {
private double balance;
public BankAccount(dou ble balance) {
this.balance = balance;
}
public double getBalance() {
return balance;
}
public double withdraw(double amount){
balance = balance - amount;
return balance;
}
public double deposit(double amount){
balance = balance + amount;
return balance;
}
}
1-Add to the BankAccount class a new method called getAmount() that read a value from the input (using the Scanner class). This method should return a double value.
and this my answare:
public double getAmount(Strin g r){
double d;
d = Double.parseDou ble(r);
Scanner s = new Scanner(System. in);
System.out.prin tln("Enter a value ");
double x = s.nextDouble();
return d;
}
" my problem in Scanner method and I try to read more and understand from net,So can you explan to in easy way about this method because i think that i do not answar the question correct "
package bank;
public class BankAccount {
private double balance;
public BankAccount(dou ble balance) {
this.balance = balance;
}
public double getBalance() {
return balance;
}
public double withdraw(double amount){
balance = balance - amount;
return balance;
}
public double deposit(double amount){
balance = balance + amount;
return balance;
}
}
1-Add to the BankAccount class a new method called getAmount() that read a value from the input (using the Scanner class). This method should return a double value.
and this my answare:
public double getAmount(Strin g r){
double d;
d = Double.parseDou ble(r);
Scanner s = new Scanner(System. in);
System.out.prin tln("Enter a value ");
double x = s.nextDouble();
return d;
}
" my problem in Scanner method and I try to read more and understand from net,So can you explan to in easy way about this method because i think that i do not answar the question correct "
Comment