Question: Identify errors and correct them of the following program: (10 marks) 1. public class AccountInfo 2. { 3. private double balance; 4. public AccountInfo() 5.
Identify errors and correct them of the following program: (10 marks)
1. public class AccountInfo
2. {
3. private double balance;
4. public AccountInfo()
5.
6. balance = 0;
7. }
8. public AccountInfo(double startBalance)
9. {
10. balance = startBalance;
11. }
12. public AccountInfo(String str)
13. {
14. balance = Double.parseDouble(str);
15. }
16. public void deposit(double amount)
17. {
18. balance += amount;
19. }
20. public void deposit(String str)
21. {
22. balance += Double.parseDouble(str)
23. }
24. public void extract(double amount)
25. {
26. balance -= amount;
27. }
28. public void extract(String str)
29. {
30. balance -= Double.parseDouble(str);
31. }
32. public void updateBalance(int b)
33. {
34. balance += b;
35. }
36. public void updateBalance(String str)
37. {
38. balance = Double.parseDouble(str);
39. }
40. public double getBalance
41. {
42. return balance;
43.
44. }
One error is already identified for you as shown below:
Line Number: 5
Error description: Missing curly bracket
Statement after correction: {
Identify 5 other errors and give their Line Number, Error description and Statement after correction.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
