+ 1
Does anyone know how to solve the problem: Checking or Saving from the Java course?
I should override the method for saving and checking account. The output is always 0.00. I don't know what I'm doing wrong. Link to the problem: https://www.sololearn.com/coach/807?ref=app
9 Answers
+ 3
amount has private access. You need to use getAmount().
Btw: you don't need an extra variable to return the value:
return getAmount() + getAmount() * 0.2;
return getAmount() + getAmount() * 0.05;
+ 1
Hello Denisa Zaharia
Can you please share your overridden methods? In the task you can not see the codes from other users.
+ 1
Thank you so much!
0
Please post your attempt so that we can look into it
0
I can't view the problem.. since I'm not a pro user. Can you please paste the problem along with your code?
0
class SavingAcc extends Account {
public SavingAcc(double amount) {
super(amount);
}
/*Override the method for saving account
public double getIncome(double amount) {
double saving;
saving = amount + amount*0.2;
return saving;
}
*/
}
class CheckingAcc extends Account {
public CheckingAcc(double amount) {
super(amount);
}
/*Override the method for checking account
public double getIncome(double amount) {
double checking;
checking = amount + amount*0.05;
return checking;
}
*/
}
0
Denisa Zaharia
Your welcome!
0
I first ran this by making the super class amount to public, but I know I am not supposed to change that to public. So I checked here and saw the getAmount method and that made more sense. The only thing is, is that I had to run the same code multiple time before it ran all correctly because I would get execution timed out as an output for some.