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

"illegal start of expression" errors in banking test program

$
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.

//java 2
//11.3
//
//test account program
   
   import javax.swing.JOptionPane;
	import java.util.Date;
   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);
			
		/////////////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);
      }
   
   }}}




I am receiving the following errors related to the last 4 lines of code
 ----jGRASP exec: javac -g TestAccount.java

TestAccount.java:119: error: illegal start of expression
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
      ^
TestAccount.java:119: error: illegal start of expression
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
             ^
TestAccount.java:119: error: ';' expected
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
                   ^
TestAccount.java:119: error: ')' expected
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
                                                           ^
TestAccount.java:119: error: illegal start of expression
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
                                                                  ^
TestAccount.java:119: error: ';' expected
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
                                                                   ^
TestAccount.java:119: error: not a statement
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
                                                                           ^
TestAccount.java:119: error: ';' expected
      public static void checkingWithdrawal(CheckingAccount chkAct, double amt) {
                                                                              ^
TestAccount.java:123: error: illegal start of expression
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
      ^
TestAccount.java:123: error: illegal start of expression
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
             ^
TestAccount.java:123: error: ';' expected
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
                   ^
TestAccount.java:123: error: ')' expected
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
                                                         ^
TestAccount.java:123: error: illegal start of expression
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
                                                                ^
TestAccount.java:123: error: ';' expected
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
                                                                 ^
TestAccount.java:123: error: not a statement
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
                                                                         ^
TestAccount.java:123: error: ';' expected
      public static void savingsWithdrawal(SavingsAccount savAct, double amt) {
                                                                            ^
16 errors

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


Viewing all articles
Browse latest Browse all 51036

Trending Articles



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