4 Replies - 420 Views - Last Post: 21 January 2013 - 04:09 PM Rate Topic: -----

#1 hambonie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 13-March 12

"can not find symbol" error while compiling acount management

Posted 21 January 2013 - 01:22 PM

I have an assignment to write an account management program that resembles and ATM. I have each component working fine but my instructor wants it to be menu based. i have created a menu with some else ifs but now the program will not compile. i have includes the test program code as well as the necessary class files. Im pretty sure a major issue is the last few lines. if i omit them i only get a couple of errors. i guess one of my main questions is where they should go.

this is the code that seems to be the main problem:
 public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
         chkAct.withdrawal(amt);
      }

      
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
         savAct.withdrawal(amt);
     
      }}}}



this is the test program:
//java 2
//11.3
//
//test account program
   
   import javax.swing.JOptionPane;
	import java.util.Date;
	
	
   public class TestCustomer {
   public static void main(String[] args) {
	
			
		/////////////menu/////////////////////////
		
		String chs = JOptionPane.showInputDialog(null,
		"Enter Your Name: ", "Account Log In", JOptionPane.INFORMATION_MESSAGE);
		Customer customer = new Customer(chs);
		
		boolean menu = true;
		while(menu) {
		
			String choice = JOptionPane.showInputDialogu(null,
			customer.getCustomerName() + "'s Banking Options for " + customer.getDate() + "\n"
			+ "\n1. Savings Deposit"
			+ "\n2. Savings Withdrawal"
			+ "\n3. Checking Deposit"
			+ "\n4. Checking Withdrawal"
			+ "\n.5 Exit\n\n","Selection Menu", JOptionPane.INFORMATION_MESSAGE);
			
			
			 
		///////////////new account constants/////
      
         Account chkAct = new CheckingAccount(0303445, 0.00, 0.5, 500.00);
         Account savAct = new SavingsAccount(0404445, 0.00, 1.5);
         
      	///////////////////////checking deposit////////////////
			
			if(choice.equals("1")) {
       
         JOptionPane.showMessageDialog(null, "New Checking Account: \n" + chkAct, 
				"New Checking Account Information", JOptionPane.INFORMATION_MESSAGE);
          
         chkAct.deposit(Double.parseDouble(JOptionPane.showInputDialog(null, 
            "Deposit amount:\n" + chkAct, "Depositing Funds", JOptionPane.INFORMATION_MESSAGE)));
				
			JOptionPane.showMessageDialog(null, "Balance: \n" + chkAct, 
			"Checking Account Overview", JOptionPane.INFORMATION_MESSAGE);
	      
      	}
         //////////////checking withdraw//////
			
			else if(choice.equals("2")){
			
			
			
			JOptionPane.showMessageDialog(null, "New Checking Account: \n" + chkAct, 
				"New Checking Account Information", JOptionPane.INFORMATION_MESSAGE);
			
			chkAct.withdrawal(Double.parseDouble(JOptionPane.showInputDialog(null, 
            "Withdrawal amount:\n" + chkAct, "Withdrawing Funds", JOptionPane.INFORMATION_MESSAGE)));
			      		  
                     
         JOptionPane.showMessageDialog(null, "Balance: \n" + chkAct, 
			"Checking Account Overview", JOptionPane.INFORMATION_MESSAGE);
          
      	} 
      	/////////////////////////savings deposit/////////////////
			
			else if(choice.equals("3")) {
      
         JOptionPane.showMessageDialog(null, "New savings account: \n" + savAct, 
				"New Savings Account Information", JOptionPane.INFORMATION_MESSAGE);
          
         savAct.deposit(Double.parseDouble(JOptionPane.showInputDialog(null, 
            "Deposit amount:\n" + savAct, "Depositing Funds", JOptionPane.INFORMATION_MESSAGE)));
				
			JOptionPane.showMessageDialog(null, "Balance: \n" + savAct, 
				"Savings Account Overview", JOptionPane.INFORMATION_MESSAGE);
				
			}	
				
			//////////savings	withdraw//////////////
			
			else if (choice.equals("4")) {
			
			JOptionPane.showMessageDialog(null, "New savings account: \n" + savAct, 
				"New Savings Account Information", JOptionPane.INFORMATION_MESSAGE);
			      
      	
         savAct.withdrawal(Double.parseDouble(JOptionPane.showInputDialog(null, 
            "Withdrawal amount:\n" + savAct, "Withdrawing Funds", JOptionPane.INFORMATION_MESSAGE)));
      		  
                     
         JOptionPane.showMessageDialog(null, "Balance: \n" + savAct, 
				"Savings Account Overview", JOptionPane.INFORMATION_MESSAGE);   
         
      }
		
		/////////////////////exit////////////////////
		else if (choice.equals("5")) {
		
		JOptionPane.showMessageDialog(null,
		"Exiting Account", "EXIT", JOptionPane.INFORMATION_MESSAGE);
		menu = false;
		}
   	
   			
		//////////////invalid selection//////////////
		
		else { 
		JOptionPane.showMessageDialog(null,
		"INVALID SELECTION! \n\n Please Enter 1-5 ", "INVALID SELECTION WARNING", JOptionPane.INFORMATION_MESSAGE);
		
		///////////////transactins/////////////////////
      
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
         chkAct.withdrawal(amt);
      }

      
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
         savAct.withdrawal(amt);
     
      }}}}
   






These are the class files:
//java 2
//11.3
//by taddei
//account class 


   
   import javax.swing.JOptionPane;
   class Account {
   
      protected int number;
      protected double balance;
      protected double annualInterestRate;
      protected java.util.Date dateCreated = new java.util.Date();
   
      public Account() {
      }
   
      public Account(int number, double balance, double annualInterestRate) {
      
         this.number = number;
      
         this.balance = balance;
      
         this.annualInterestRate = annualInterestRate;
      
      }
   
      public java.util.Date getdate() {
      
         return dateCreated;
      
      }
   
      public int getNumber() {
      
         return number;
      
      }
   
      public void setNumber(int number) {
      
         this.number = number;
      
      }
   
      public double getBalance() {
      
         return balance;
      
      }
   
      public void setBalance(double balance) {
      
         this.balance = balance;
      
      }
   
      public double deposit(double deposit) {
      
         balance += deposit;
      
         return balance;
      
      }
   
      public double withdrawal(double withdraw) {
      
         if(balance >= withdraw)
            this.balance -= withdraw;
         else
            JOptionPane.showMessageDialog(null, "Over Draft Warning! " + balance);
      
         return balance;
      
      }
   
      public double getAnnualInterestRate() {
      
         return annualInterestRate;
      
      }
   
      public void setAnnualInterestRate(double annualInterestrate) {
      
      
         this.annualInterestRate = annualInterestrate;
      
      }
   
      public double getMonthlyInterestRate() {
      
         double monthlyInterest = (annualInterestRate / 1200) * balance;
      
         return monthlyInterest;
      
      }
   
      public String toString() {
         String details = "Account Number = " + number + "\nBalance = " + balance + 
            "\nInterest Rate = " + annualInterestRate + "\n\nDate Created:\n" + dateCreated;
         return details;
      }
   
   }




//java 2
//11.3
//by taddei
//checking account class
   
   import javax.swing.JOptionPane;
   class CheckingAccount extends Account {
      double overdraft;
   
      CheckingAccount(int number, double balance, double annualInterestRate, double overdraft) {
         super(number, balance, annualInterestRate);
         this.overdraft = overdraft; 
      }
        
      public double withdrawal(double amt) {
      
         if((balance + overdraft) >= amt)
            this.balance -= amt;
         else
            JOptionPane.showMessageDialog(null, "Over Draft! = "+balance, "Over Draft Warning", JOptionPane.INFORMATION_MESSAGE);
      
         return balance;
      }
   
      public String toString() {
         String details = "Account Number = " + number + "\nBalance = " + balance + "\nInterest Rate = " + 
            annualInterestRate + "\nOverdraft Limit = " + overdraft + "\n\nDate Created:\n" + dateCreated ;
      
         return details;
      }
    
   }


//java 2
//11.3
//by  taddei
//savings account class


class SavingsAccount extends Account {
    
    SavingsAccount(int number, double balance, double annualInterestRate) {
       super(number, balance, annualInterestRate);
    }

 }



Here is the test program that works (but is not menu based)
//java 2
//11.3
//by taddei
//test account program
   
   import javax.swing.JOptionPane;
   public class TestAccount {
      public static void main(String[] args) {
      
         Account chkAct = new CheckingAccount(0303445, 0.00, 0.5, 500.00);
         Account savAct = new SavingsAccount(0404445, 0.00, 1.5);
         
      	///////////////////////checking////////////////
       
         JOptionPane.showMessageDialog(null, "New Checking Account: \n" + chkAct, 
				"New Checking Account Information", JOptionPane.INFORMATION_MESSAGE);
          
         chkAct.deposit(Double.parseDouble(JOptionPane.showInputDialog(null, 
            "Deposit amount:\n" + chkAct, "Depositing Funds", JOptionPane.INFORMATION_MESSAGE)));      
      	
         chkAct.withdrawal(Double.parseDouble(JOptionPane.showInputDialog(null, 
            "Withdrawal amount:\n" + chkAct, "Withdrawing Funds", JOptionPane.INFORMATION_MESSAGE)));
      		  
         chkAct.deposit(Double.parseDouble(JOptionPane.showInputDialog(null, 
            "Deposit amount:\n" + chkAct, "Depositing Funds", JOptionPane.INFORMATION_MESSAGE)));
      		
         chkAct.withdrawal(Double.parseDouble(JOptionPane.showInputDialog(null, 
            "Withdrawal amount:\n" + chkAct, "Withdrawing Funds", JOptionPane.INFORMATION_MESSAGE)));
      		   
         				  
         chkAct.deposit(Double.parseDouble(JOptionPane.showInputDialog(null, 
            "Deposit amount:\n" + chkAct, "Depositing Funds", JOptionPane.INFORMATION_MESSAGE))); 
            
         JOptionPane.showMessageDialog(null, "Balance: \n" + chkAct, 
			"Checking Account Overview", JOptionPane.INFORMATION_MESSAGE);
          
      	 
      	/////////////////////////savings/////////////////
      
         JOptionPane.showMessageDialog(null, "New savings account: \n" + savAct, 
				"New Savings Account Information", JOptionPane.INFORMATION_MESSAGE);
          
         savAct.deposit(Double.parseDouble(JOptionPane.showInputDialog(null, 
            "Deposit amount:\n" + savAct, "Depositing Funds", JOptionPane.INFORMATION_MESSAGE)));      
      	
         savAct.withdrawal(Double.parseDouble(JOptionPane.showInputDialog(null, 
            "Withdrawal amount:\n" + savAct, "Withdrawing Funds", JOptionPane.INFORMATION_MESSAGE)));
      		  
         savAct.deposit(Double.parseDouble(JOptionPane.showInputDialog(null, 
            "Deposit amount:\n" + savAct, "Depositing Funds", JOptionPane.INFORMATION_MESSAGE)));
      		
         savAct.withdrawal(Double.parseDouble(JOptionPane.showInputDialog(null, 
            "Withdrawal amount:\n" + savAct, "Withdrawing Funds", JOptionPane.INFORMATION_MESSAGE)));
      		   
         				  
         savAct.deposit(Double.parseDouble(JOptionPane.showInputDialog(null, 
            "Deposit amount:\n" + savAct, "Depositing Funds", JOptionPane.INFORMATION_MESSAGE))); 
            
         JOptionPane.showMessageDialog(null, "Balance: \n" + savAct, 
				"Savings Account Overview", JOptionPane.INFORMATION_MESSAGE);   
         
      }
   	
   	///////////////transactins/////////////////////
      
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
         chkAct.withdrawal(amt);
      }
      
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
         savAct.withdrawal(amt);
      }
   
   }
      
   





Is This A Good Question/Topic? 0
  • +

Replies To: "can not find symbol" error while compiling acount management

#2 Ryano121  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 1362
  • View blog
  • Posts: 3,002
  • Joined: 30-January 11

Re: "can not find symbol" error while compiling acount management

Posted 21 January 2013 - 01:23 PM

"Cannot find symbol" - so what symbol? What is the actual error message?

It would also be good if you posted only the relevant code to the error, just so we don't have to go trawling through loads of files finding the issue :)
Was This Post Helpful? 0
  • +
  • -

#3 hambonie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 13-March 12

Re: "can not find symbol" error while compiling acount management

Posted 21 January 2013 - 01:25 PM

PS i realize there are some extra curly braces at the end of the test program. i got frustrated and thought they might help :(
Was This Post Helpful? 0
  • +
  • -

#4 hambonie  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 34
  • Joined: 13-March 12

Re: "can not find symbol" error while compiling acount management

Posted 21 January 2013 - 03:52 PM

sorry, the can't find symbol error comes up if i eliminate the last two lines of code i get these two errors.

TestCustomer.java:18: error: cannot find symbol
		Customer customer = new Customer(chs);
		^
  symbol:   class Customer
  location: class TestCustomer
TestCustomer.java:18: error: cannot find symbol
		Customer customer = new Customer(chs);
		                        ^
  symbol:   class Customer
  location: class TestCustomer
2 errors

 ----jGRASP wedge2: exit code for process is 1.
 ----jGRASP: operation complete.



if the lines remain (which worked in my original test program (without a menue), i get all of this

 ----jGRASP exec: javac -g TestCustomer.java

TestCustomer.java:118: error: illegal start of expression
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
      ^
TestCustomer.java:118: error: illegal start of expression
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
             ^
TestCustomer.java:118: error: ';' expected
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
                   ^
TestCustomer.java:118: error: ')' expected
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
                                                           ^
TestCustomer.java:118: error: illegal start of expression
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
                                                                  ^
TestCustomer.java:118: error: ';' expected
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
                                                                   ^
TestCustomer.java:118: error: not a statement
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
                                                                           ^
TestCustomer.java:118: error: ';' expected
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
                                                                              ^
TestCustomer.java:123: error: illegal start of expression
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
      ^
TestCustomer.java:123: error: illegal start of expression
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
             ^
TestCustomer.java:123: error: ';' expected
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
                   ^
TestCustomer.java:123: error: ')' expected
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
                                                         ^
TestCustomer.java:123: error: illegal start of expression
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
                                                                ^
TestCustomer.java:123: error: ';' expected
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
                                                                 ^
TestCustomer.java:123: error: not a statement
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
                                                                         ^
TestCustomer.java:123: error: ';' expected
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
                                                                            ^
TestCustomer.java:126: error: reached end of file while parsing
      }}}}
          ^
17 errors

 ----jGRASP wedge2: exit code for process is 1.
 ----jGRASP: operation complete.


Was This Post Helpful? 0
  • +
  • -

#5 darek9576  Icon User is offline

  • D.I.C Lover

Reputation: 198
  • View blog
  • Posts: 1,692
  • Joined: 13-March 10

Re: "can not find symbol" error while compiling acount management

Posted 21 January 2013 - 04:09 PM

It says:
symbol: class Customer
meaning that Customer class is not visible or not defined etc. Then you jave some missing syntax. It tells you the line of the error and what is expected. Pretty easy to fix that.
Was This Post Helpful? 1
  • +
  • -

Page 1 of 1