Results 21 to 27 of 27
- 01-09-2012, 08:32 PM #21
- 01-09-2012, 08:51 PM #22
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,377
- Blog Entries
- 7
- Rep Power
- 17
Re: Error ' Cannot find symbol class UserAccount"
I'd say the OP should study the tutorials some more because s/he obviously doesn't know what s/he is doing; all tips are a waste of effort because the OP wouldn't understand them either ...
kind regards,
JosWhen people rob a bank they get a penalty; when banks rob people they get a bonus.
- 01-09-2012, 09:35 PM #23
Member
- Join Date
- Jan 2012
- Posts
- 31
- Rep Power
- 0
- 01-09-2012, 10:03 PM #24
Member
- Join Date
- Jan 2012
- Posts
- 31
- Rep Power
- 0
Re: Error ' Cannot find symbol class UserAccount"
Hi
This is were I am now. It is compiling but it is throwing an error
Java Code:import java.util.*; class accountAR { Account[] Accounts = new Account [10]; public int x; Scanner input = new Scanner(System.in); public void mainMenu(){ int selection; System.out.print("Welcome to the Automated Teller Machine!\n"); System.out.println("Select from the following menu options below:\n"); System.out.println("========================"); System.out.println("| [1] Check Balance |"); System.out.println("| [2] Withdrawal |"); System.out.println("| [3] Deposit |"); System.out.println("| [4] Exit |"); System.out.println("========================"); System.out.print("Please select your option now: "); selection =input.nextInt(); switch (selection){ case 1: viewBalance(); break; case 2: withdrawFunds(); break; case 3: depositFunds(); break; case 4: System.out.println("Thank you for using ATM! \n Goodbye! \n"); } } public void setX (int c) { x = c; } public void viewBalance() { int selection1; System.out.println("You have selected Balance.\n"); System.out.println("\t-- Your Current Balance is:$ " + Accounts[x].getbalance()); System.out.println("Return to main menu? \n [1] for YES \n"); selection1 =input.nextInt(); switch (selection1){ case 1: mainMenu(); break; } } //Method to withdraw money public void withdrawFunds() { int withdrawSelection; System.out.println("Amount to withdraw: "); System.out.println("[1] - $20"); System.out.println("[2] - $40"); System.out.println("[3] - $50"); System.out.println("[4] - $100"); System.out.println("[5] - MAIN MENU"); System.out.print("Please select your option now: "); withdrawSelection =input.nextInt(); switch (withdrawSelection){ case 1: Accounts[x].withdraw(20); mainMenu(); break; case 2: Accounts[x].withdraw(40); mainMenu(); break; case 3: Accounts[x].withdraw(50); mainMenu(); break; case 4: Accounts[x].withdraw(100); mainMenu(); break; case 5: mainMenu(); break; } } // method for choosing how much to deposit public void depositFunds(){ int addSelection; System.out.println("Amount to deposit: "); System.out.println("[1] - $20"); System.out.println("[2] - $40"); System.out.println("[3] - $50"); System.out.println("[4] - $100"); System.out.println("[5] - MAIN MENU"); System.out.print("Please select your option now: "); addSelection =input.nextInt(); switch (addSelection){ case 1: Accounts[x].deposit(20); mainMenu(); break; case 2: Accounts[x].deposit(40); mainMenu(); break; case 3: Accounts[x].deposit(50); mainMenu(); break; case 4: Accounts[x].deposit(100); mainMenu(); break; case 5: mainMenu(); break; } } public accountAR () {} // Start main public static void main (String [] args){ accountAR a = new accountAR (); Scanner input1 = new Scanner(System.in); // Create 10 account objects Account[] Account = new Account [10]; // loop to create 10 accounts with balance of 50 for (int p = 0; p<10;p++) { Account [p] = new Account (); Account [p].setId (p); Account [p].setBalance(50); } // Start the welcome message int p; System.out.println("Please enter your ID number\n"); p =input1.nextInt(); a.setX(p); // If id is incorrect print message or start mainMenu if (p > Account.length) { System.out.println ("Please re-enter your ID number\n"); } else { a.mainMenu(); } } }
the error is:
Exception in thread "main" java.lang.NullPointerException
at accountAR.depositFunds(accountAR.java:121)
at accountAR.mainMenu(accountAR.java:37)
at accountAR.main(accountAR.java:176)Last edited by r1b; 01-09-2012 at 10:05 PM.
- 01-09-2012, 10:07 PM #25
Re: Error ' Cannot find symbol class UserAccount"
There is a variable on line 121 that has a null value. Find which variable is null and then backtrack to see why that variable does not have a valid value. If you can not see which variable is null, add a println just before line 121 and print the values of all the variables used on 121.
- 01-09-2012, 11:43 PM #26
Member
- Join Date
- Jan 2012
- Posts
- 31
- Rep Power
- 0
Re: Error ' Cannot find symbol class UserAccount"
Thanks for all your help today Norm.
- 01-10-2012, 11:40 AM #27
- Join Date
- Sep 2008
- Location
- Voorschoten, the Netherlands
- Posts
- 11,377
- Blog Entries
- 7
- Rep Power
- 17
Similar Threads
-
"Cannot find symbol" error
By MBD in forum New To JavaReplies: 5Last Post: 09-27-2011, 02:41 PM -
"cannot find symbol" error
By droidus in forum New To JavaReplies: 2Last Post: 09-07-2011, 07:43 AM -
Do you know why I'm getting "cannot find symbol" error?
By basla in forum New To JavaReplies: 5Last Post: 04-24-2011, 03:21 PM -
Error "can not find symbol variable"
By FullMetalHollow in forum New To JavaReplies: 5Last Post: 10-04-2009, 09:51 PM -
"Cannont find symbol Constructor" error
By Welsh in forum New To JavaReplies: 7Last Post: 01-25-2008, 12:12 AM


LinkBack URL
About LinkBacks
Reply With Quote

Bookmarks