i dont know that my error is, my code for balance is not working properly and im having a problem with my if else statements, they say i lack this "{" but i dont know where
to put it

{

	/**
	 * @param args
	 */
	public static void main(String[] args) {
	
    String a =(JOptionPane.showInputDialog(null, "Automatic Teller Machine\n [B] Balance Inquiry\n [D]Deposit\n [W] Withdrawal\n [Q] Quit\n Select you Options:  ","Automatic Teller Machine",JOptionPane.PLAIN_MESSAGE));
   
   String B= "B";
   String D="D";
   String W="W";
   
   float balance= 0;
   int deposit = 0;
   int withdraw= 0;
   int bal = 0;
   int wht = 0;
int ans = 0;
int trans = 0;
   
   if(a.equalsIgnoreCase(B))
	{
	   JOptionPane.showMessageDialog(null, "Your Balance is: ","BALANCE INQUIRY"+ balance,JOptionPane.PLAIN_MESSAGE );
		
	   ans=JOptionPane.showConfirmDialog(null, "Would you like to generate bank slip?","Generate Bank Slip",JOptionPane.YES_NO_OPTION);
		
		do { if (ans == 1);
		{	 //no
	trans =JOptionPane.showConfirmDialog(null,"Would You Like Another Transaction?","Another Transaction",JOptionPane.YES_NO_OPTION);
		
	if (trans == 1)
		
		{
		JOptionPane.showMessageDialog(null, "Thanks For Using My Program!!");
		System.exit(0);
		}

		else if (trans == 0)
		{ 
			 String b =(JOptionPane.showInputDialog(null, "Automatic Teller Machine\n [B] Balance Inquiry\n [D]Deposit\n [W] Withdrawal\n [Q] Quit\n Select you Options:  ","Automatic Teller Machine",JOptionPane.PLAIN_MESSAGE));
		}
		
		}
		}while   (ans == 0); // yes
			JOptionPane.showMessageDialog(null, "BALANCE INQUIRY \n AMOUNT BALANCE: "+ balance+ "\nPrinting Bank slip.....");
		
		
		
		
		}
	
	
	
	}
   
   
   
   
   
   
 /*
    else if (a.equalsIgnoreCase(D))
    {
	
	int dep =Integer.parseInt(JOptionPane.showInputDialog (null,"Enter Your Deposit Amount" )); 
	   balance = dep - wht;

	
	
	ans=JOptionPane.showConfirmDialog(null, "Would you like to generate bank slip?","Generate Bank Slip",JOptionPane.YES_NO_OPTION);
	
	if (ans == 1){ //no
JOptionPane.showConfirmDialog(null,"Would You Like Another Transaction?","Another Transaction",JOptionPane.YES_NO_OPTION);
	if (trans == 1)
	{
	JOptionPane.showMessageDialog(null, "Thanks For Using My Program!!");
	}
	else if (trans == 0)
	{ 
		 String c =(JOptionPane.showInputDialog(null, "Automatic Teller Machine\n [B] Balance Inquiry\n [D]Deposit\n [W] Withdrawal\n [Q] Quit\n Select you Options:  ","Automatic Teller Machine",JOptionPane.PLAIN_MESSAGE));
	
	}
	
	}

	else if (ans == 0){ // yes
		JOptionPane.showMessageDialog(null, "DEPOSIT INQUIRY \n AMOUNT DEPOSIT: "+ dep+ "\nPrinting Bank slip.....");
	}
	
    }
	
    else if (a.equalsIgnoreCase(W))
	
    	 wht= Integer.parseInt(JOptionPane.showInputDialog(null," Enter the Withdrawal Amount:"));
	 
   
   if (balance <  wht){
	   JOptionPane.showMessageDialog(null, "Insufficient Amount");
   }
   else if (balance >= wht){
	   ans=JOptionPane.showConfirmDialog(null, "Would you like to generate bank slip?","Generate Bank Slip",JOptionPane.YES_NO_OPTION);
   }
		if (ans == 1){ //no
	JOptionPane.showConfirmDialog(null,"Would You Like Another Transaction?","Another Transaction",JOptionPane.YES_NO_OPTION);
		if (trans == 1)
		{
		JOptionPane.showMessageDialog(null, "Thanks For Using My Program!!");
		}
		else if (trans == 0)
		{ 
			 String d =(JOptionPane.showInputDialog(null, "Automatic Teller Machine\n [B] Balance Inquiry\n [D]Deposit\n [W] Withdrawal\n [Q] Quit\n Select you Options:  ","Automatic Teller Machine",JOptionPane.PLAIN_MESSAGE));
		}  
        }
		else if (ans == 0){ // yes
		JOptionPane.showMessageDialog(null, "DEPOSIT INQUIRY \n AMOUNT DEPOSIT: "+ withdraw+ "\nPrinting Bank slip.....");
		}
		
		
		
*/   
   
	}

I don't see a class declaration at the top of the code. It should be just before your first curly brace ({) at the top. Something like:

public class Teller

When I put that in, the code ran.

You really should have one outer loop that takes in the user's input, then compares it to your menu choices. In your example, you show the choices, get the user's choice, then after the operation (in this case, a balance inquiry), you enter a loop to get the user's next choice. With one big loop running the entire program, when you are done with an operation (balance, deposit, etc.), you just go back to the top of the loop and get the next choice. Something like:

// Do this until the user presses "q" or "Q"
while (1)
{
	// Get choice
	String a =(JOptionPane.showInputDialog(null, "Automatic Teller Machine\n [B] Balance Inquiry\n [D]Deposit\n [W] Withdrawal\n [Q] Quit\n Select you Options:  ","Automatic Teller Machine",JOptionPane.PLAIN_MESSAGE));

	// Exit?
	if(a.equalsIgnoreCase("q"))
	{
                // Do exit stuff...
		System.exit(0);
	}

	// Balance
	if(a.equalsIgnoreCase("b"))
	{
		// Do balance stuff...
	}

	// Deposit
	if(a.equalsIgnoreCase("d"))
	{
		// Do deposit stuff...
	}

//end of main loop
}

I don't see a class declaration at the top of the code. It should be just before your first curly brace ({) at the top. Something like:

public class Teller

When I put that in, the code ran.

You really should have one outer loop that takes in the user's input, then compares it to your menu choices. In your example, you show the choices, get the user's choice, then after the operation (in this case, a balance inquiry), you enter a loop to get the user's next choice. With one big loop running the entire program, when you are done with an operation (balance, deposit, etc.), you just go back to the top of the loop and get the next choice. Something like:

// Do this until the user presses "q" or "Q"
while (1)
{
	// Get choice
	String a =(JOptionPane.showInputDialog(null, "Automatic Teller Machine\n [B] Balance Inquiry\n [D]Deposit\n [W] Withdrawal\n [Q] Quit\n Select you Options:  ","Automatic Teller Machine",JOptionPane.PLAIN_MESSAGE));

	// Exit?
	if(a.equalsIgnoreCase("q"))
	{
                // Do exit stuff...
		System.exit(0);
	}

	// Balance
	if(a.equalsIgnoreCase("b"))
	{
		// Do balance stuff...
	}

	// Deposit
	if(a.equalsIgnoreCase("d"))
	{
		// Do deposit stuff...
	}

//end of main loop
}

i have a class declaration, sir im new to java and may i just ask what does while (1) up there propose? what does it do in there?

OK, I didn't see a class declaration in the post; perhaps it got left out.

A while loop loops while the condition in the parentheses is true. So, "while(1)" will loop forever. However, in the example I posted, if the user types a "q" or "Q", it will call "System.exit(0)", and end the program. You can have code like this, just as long as you be sure to break out of the loop somehow, either using the "break" statement:

while(1)
{
    if (a.equalsIgnoreCase("q"))
    {
        break;
    }
}

// execution will continue here..

or, as was done in my previous post, calling "System.exit(0)".

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.