Quantcast
Channel: Programming Forums
Viewing all articles
Browse latest Browse all 51036

"can not find symbol" error while compiling acount management

$
0
0
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);
      }
   
   }
      
   




Viewing all articles
Browse latest Browse all 51036

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>