Hi everyone, Java newbie here. I'm trying to compile this code, but I'm getting errors on lines 40 and 42 saying it can't find the symbols balance and name that I defined in the beginning of the code. I'm not quite sure what I did wrong, and would appreciate any help. Thanks!
1. import java.io.*;
2. import java.util.*;
3. public class BankAccount
4. {
5. public BankAccount(double b, String n)
6. {
7. balance=b;
8. name=n;
9. }
10. public double deposit(double d)
11. {
12. balance=balance+d;
13. return balance;
14.
15. }
16. public double withdraw(double w)
17. {
18. balance=balance-w;
19. return balance;
20.
21. }
22.
23.
24. }
25. public double balance;
26. public String name;
27.
28. class Tester
29. {
30. public static void main(String args[])
31. {
32. Scanner kbReader=new Scanner(System.in);
33. System.out.print("Initial Deposit: ");
34. double b=kbReader.nextInt();
35. System.out.print("Account Name: ");
36. String n=kbReader.nextLine();
37.
38. BankAccount myAccount=new BankAccount(b, n);
39. myAccount.deposit(505.22);
40. System.out.println(balance);
41. myAccount.withdraw(100.00);
42. System.out.print("The "+name+"account balance is, $"+balance);
43. }
44. }