Three Syntax error and i tried everything I know which isn't much

Syntax error x 3...HELP

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 4224 Views - Last Post: 03 November 2010 - 06:29 PM Rate Topic: -----

#1 boosh  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 14-January 10

Three Syntax error and i tried everything I know which isn't much

Posted 01 November 2010 - 05:17 PM

I get three syntax errors and I can't seem to fix the and know it keeps telling me there is no main? But I do have the main.....AAAHHHH !!! Any help would be much welcomed. Here is the code so far.
import javax.swing.*;
import java.io.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.Color;
import java.awt.Component;
import javax.swing.border.*;
import java.util.*;
import java.awt.*;



public class ATMC extends JFrame  
{
	

	private static final long serialVersionUID = 1L;
	public static int buttonValue = 0;
    public  boolean dotOn = false;
    public static double amt1 = 0.0f;
    public static JTextArea showArea;
    public JTextField dataField;
    public static JButton disAccBalance;
    public static JButton makeDeposit;
    public static JButton makeWithdraw;
    public static JButton enter,zeroButt, oneButt, twoButt, threeButt, fourButt, fiveButt, sixButt, sevenButt, eightButt, nineButt,dotButt;
    public static boolean customerID = false;
    public static String customerID1 "";}

 @SuppressWarnings("deprecation")
public void ATMClient( )
{

	String thisLine;
	final String[] fullText = new String[10];
	String id = " ";
	int counter = 0;

	try
	{
	FileInputStream fis = new FileInputStream("test.dat");
	DataInputStream myInput = new DataInputStream(fis);
	while ((thisLine = () != null);
		{
		System.out.println(thisLine);
		fullText[counter] = thisLine;
		counter++;
       		}
	}catch(IOException e){System.out.println("problem");}
// Create panel p1 for the buttons and set GridLayout
    final JPanel p1 = new JPanel();
    p1.setLayout(new GridLayout(4, 3));
	oneButt = new JButton("1");
    p1.add(oneButt);
    
    // Handler for "1" button action
        oneButt.addActionListener(new ActionListener()
	{
            public void actionPerformed(ActionEvent e)
		{
                	dataField.setText(dataField.getText()+"1");
		}
        });
    	twoButt = new JButton("2");
    	p1.add(twoButt);
    	// Handler for "2" button action
        twoButt.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                 dataField.setText(dataField.getText()+"2");


            }
        });
    threeButt = new JButton("3");
    p1.add(threeButt);
    // Handler for "3" button action
        threeButt.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                dataField.setText(dataField.getText()+"3");


            }
        });
    fourButt = new JButton("4");
    p1.add(fourButt);
    // Handler for "4" button action
        fourButt.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                 dataField.setText(dataField.getText()+"4");

            }
        });

    fiveButt = new JButton("5");
    p1.add(fiveButt);
    // Handler for "5" button action
        fiveButt.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                 dataField.setText(dataField.getText()+"5");

            }
        });
sixButt = new JButton("6");
    p1.add(sixButt);
    // Handler for "6" button action
        sixButt.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                 dataField.setText(dataField.getText()+"6");


            }
        });
 sevenButt = new JButton("7");
    p1.add(sevenButt);
    // Handler for "7" button action
        sevenButt.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
               dataField.setText(dataField.getText()+"7");

            }
        });
    eightButt = new JButton("8");
    p1.add(eightButt);
    // Handler for "8" button action
        eightButt.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                  dataField.setText(dataField.getText()+"8");


            }
        });
    nineButt = new JButton("9");
    p1.add(nineButt);
    // Handler for "9" button action
        nineButt.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                  dataField.setText(dataField.getText()+"9");
                  
            }
        });
    zeroButt = new JButton("0");
    p1.add(zeroButt);
    // Handler for "0" button action
        zeroButt.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                {
                dataField.setText(dataField.getText()+"0");
                  }
            }
        });
    dotButt = new JButton(".");
    p1.add(dotButt);
    // Handler for "." button action
        dotButt.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                if (dotOn = true)
                dataField.setText(dataField.getText()+".");


            }
        });
enter = new JButton("ENTER");
    p1.add(enter);
    // Handler for "ENTER" button action
        enter.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){

  if (disAccBalance.isEnabled())
 {
  if (buttonValue == 1)
            {
		if (dataField.getText() != "")
		  {
		    String gAmt = dataField.getText();
                    amt1 = amt1 + Double.parseDouble(gAmt);
                    showArea.setText("");

                    showArea.append("TOTAL BALANCE = " +amt1);
		  }

             }

           else if (buttonValue == 2)
	       {
		   if (dataField.getText() != "")
		   {
		    	String gAmt = dataField.getText();
                    if (amt1 > Double.parseDouble(gAmt))
                    {
                    amt1 = amt1 - Double.parseDouble(gAmt);
                    showArea.setText("");

                    showArea.append("WITHDRAW AMOUNT = " + gAmt + " " + "\nTOTAL BALANCE = " +amt1);
		  }
              else {showArea.setText("INSUFFICIENT AMOUNT");}
                }

}	

else  {
          for(int i =0; i<fullText.length;i++)
           {

            int chk = 0;
	 Scanner scanner = new Scanner(fullText[i]);
	 scanner.useDelimiter(" ");
	 if ( scanner.hasNext() )
           {

       		if(dataField.getText().equals(scanner.next()))
	  	  {
                disAccBalance.setEnabled(true);
		        makeDeposit.setEnabled(true);
		        makeWithdraw.setEnabled(true);
                        
                dataField.setText("");
          		String FirstName = scanner.next();
                showArea.setText("");

         		showArea.append("WELCOME\n " + FirstName);

      			String SecondName = scanner.next();

     			showArea.append(" " +SecondName+"\n");

			    String amt = scanner.next();
                        			
			    amt1 = Double.parseDouble(amt);
                chk = 1;
                 

                       break;


                   }
        	
          }
         else
		 {dataField.setText("");
                   // showArea.setText("CUSTOMER-ID NOT FOUND");
                  System.out.println("Empty or invalid line. Unable to process.");}

          scanner.close();
            if (chk == 0){showArea.setText("");
                    showArea.setText("CUSTOMER-ID NOT FOUND");
                         }
        }


        }


        }
// Create panel p2 to hold a text field and p1
    JPanel p2 = new JPanel(new BorderLayout());

    dataField =new JTextField("",5);
    //dataField.setLineWrap(true);
   // dataField.setWrapStyleWord(true);
    dataField.setEditable(false);
    dataField.setBorder(BorderFactory.createEtchedBorder(1));
    p2.add(dataField,BorderLayout.CENTER);
    JPanel p3 = new JPanel();
    p3.setLayout(new GridLayout(3, 1));

    disAccBalance = new JButton("Display account balance");
    p3.add(disAccBalance);
    // Handler for "display account balance" button action
        disAccBalance.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                   showArea.setText("");
                   showArea.setText("YOUR BALANCE IS = " +amt1);

            }
        });

    makeDeposit = new JButton("Make a deposit");
    p3.add(makeDeposit);
    // Handler for "Make a deposit" button action
        makeDeposit.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){

                showArea.setText("");
                dataField.setText("");
                showArea.setText("           ENTER THE DEPOSIT AMOUNT ");
                buttonValue = 1;
            }
        });

   makeWithdraw = new JButton("Make a withdrawal");
    p3.add(makeWithdraw);
    // Handler for "Make a withdrawal" button action
        makeWithdraw.addActionListener(new ActionListener(){
            public void actionPerformed(ActionEvent e){
                 showArea.setText("");
                 dataField.setText("");
                 showArea.setText("           ENTER THE WITHDRAWAL AMOUNT ");
                 buttonValue = 2;

            }
        });

    p2.add(p3, BorderLayout.NORTH);
    p2.add(p1, BorderLayout.SOUTH);

    // Add contents to the frame
    add(p2, BorderLayout.WEST);
    // Text Area for containg output messages
    showArea=new JTextArea("WELCOME! please enter your customer ID into Key pad and press the ENTER button\n", 10, 75);
    showArea.setLineWrap(true);
    showArea.setWrapStyleWord(true);
    showArea.setEditable(false);
    showArea.setBorder(BorderFactory.createBevelBorder(10, Color.lightGray, Color.yellow));
    showArea.setFont(new Font("SansSerif", Font.BOLD,12));
    showArea.setForeground(Color.darkGray);
    add(showArea,BorderLayout.CENTER);

}


    //Main method
public void main(String[] args)
{
	ATMClient frame = new ATMClient();
    disAccBalance.setEnabled(false);
    makeDeposit.setEnabled(false);
    makeWithdraw.setEnabled(false);
    frame.setTitle("First Bauer Bank ATM");
    frame.setLocationRelativeTo(null); // Center the frame
    frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    frame.setSize(800, 250);
    frame.setVisible(true);
  
}

private String extracted111(DataInputStream myInput) throws IOException {
	return extracted111(myInput);
}


private String extracted11(DataInputStream myInput) throws IOException {
	return extracted(myInput);
}


private String extracted(DataInputStream myInput) throws IOException {
	return myInput.readLine()


Done with Eclipse

Is This A Good Question/Topic? 0
  • +

Replies To: Three Syntax error and i tried everything I know which isn't much

#2 Kilorn  Icon User is offline

  • XNArchitect
  • member icon



Reputation: 1356
  • View blog
  • Posts: 3,528
  • Joined: 03-May 10

Re: Three Syntax error and i tried everything I know which isn't much

Posted 01 November 2010 - 05:20 PM

Paste the errors that you're getting and I'll try to walk you through each one. That's a lot of code to go through without knowing where to start, and the specific error messages are usually a big help.
Was This Post Helpful? 0
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6063
  • View blog
  • Posts: 23,515
  • Joined: 23-August 08

Re: Three Syntax error and i tried everything I know which isn't much

Posted 01 November 2010 - 06:29 PM

Why did you post a Java question in C#????

Moved to Java
Was This Post Helpful? 0
  • +
  • -

#4 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Three Syntax error and i tried everything I know which isn't much

Posted 01 November 2010 - 07:09 PM

You have a main() but it is not declared static
Was This Post Helpful? 0
  • +
  • -

#5 boosh  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 14-January 10

Re: Three Syntax error and i tried everything I know which isn't much

Posted 01 November 2010 - 08:21 PM

View PostKilorn, on 01 November 2010 - 04:20 PM, said:

Paste the errors that you're getting and I'll try to walk you through each one. That's a lot of code to go through without knowing where to start, and the specific error messages are usually a big help.


Sorry I thought I posted in java but here is what I have,
First error line 29
Multiple markers at this line
-Syntax error, insert “}” to complete ClassBody
-Syntax error, insert “enum Identifier” to complete EnumHeaderName
-Syntax error, insert “EnumBody” to complete EnumDeclaration
-Syntax error, on token “String”, delete this token

Second error line 44
-Syntax error, on token “{“, invalid Expression

Third error line 348
Multiple markers at this line
-Syntax error, insert “}” to complete Expression
-Syntax error, insert “}” to complete classBody
-Syntax error, insert “}” to complete ClassBody
-Syntax error, insert “}” to complete Expression
-Syntax error, insert “}” to complete BlockStatments
-Syntax error, insert “}” to complete MethodBody
-Syntax error, insert “}” to complete Statement
-Syntax error, insert “}” to complete MethodBody
-Syntax error, insert “}” to complete Statement
Was This Post Helpful? 0
  • +
  • -

#6 Dogstopper  Icon User is offline

  • The Ninjaducky
  • member icon



Reputation: 2872
  • View blog
  • Posts: 11,031
  • Joined: 15-July 08

Re: Three Syntax error and i tried everything I know which isn't much

Posted 01 November 2010 - 08:28 PM

View Postpbl, on 01 November 2010 - 08:09 PM, said:

You have a main() but it is not declared static


This is one of the main errors. Secondly, you should format your code better. When you do, it will reveal all that is wrong with your code. In eclipse, right click in the editor window, select Source, then click Format OR push Ctrl+Shift+F to format.
Was This Post Helpful? 0
  • +
  • -

#7 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Three Syntax error and i tried everything I know which isn't much

Posted 01 November 2010 - 08:32 PM

	public static JButton enter,zeroButt, oneButt, twoButt, threeButt, fourButt, fiveButt, sixButt, sevenButt, eightButt, nineButt,dotButt;
	public static boolean customerID = false;
	public static String customerID1 "";}    <----- extra } here


		DataInputStream myInput = new DataInputStream(fis);
		while ((thisLine = () != null);    <--- thisLine = () ?????
		{


		private String extracted(DataInputStream myInput) throws IOException {
			return myInput.readLine()    <---- missing ;
                } <---- missing }


Was This Post Helpful? 0
  • +
  • -

#8 boosh  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 14-January 10

Re: Three Syntax error and i tried everything I know which isn't much

Posted 01 November 2010 - 10:44 PM

View Postpbl, on 01 November 2010 - 07:32 PM, said:

	public static JButton enter,zeroButt, oneButt, twoButt, threeButt, fourButt, fiveButt, sixButt, sevenButt, eightButt, nineButt,dotButt;
	public static boolean customerID = false;
	public static String customerID1 "";}    <----- extra } here


		DataInputStream myInput = new DataInputStream(fis);
		while ((thisLine = () != null);    <--- thisLine = () ?????
		{


		private String extracted(DataInputStream myInput) throws IOException {
			return myInput.readLine()    <---- missing ;
                } <---- missing }


Ok I tried the source format and that gave me a few more issues so I got those fixed but the "public static main (String[] args)" keeps trying to get me to change to "void". Also tried multiple fixes for the above 3 issues but to no avail. I think the source format caused a bit more havok and I bit off more than I could chew.
Was This Post Helpful? 0
  • +
  • -

#9 Handler  Icon User is offline

  • D.I.C Head

Reputation: 15
  • View blog
  • Posts: 199
  • Joined: 01-April 10

Re: Three Syntax error and i tried everything I know which isn't much

Posted 01 November 2010 - 10:58 PM

then add the void to
Was This Post Helpful? 0
  • +
  • -

#10 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Three Syntax error and i tried everything I know which isn't much

Posted 01 November 2010 - 11:14 PM

View Postboosh, on 01 November 2010 - 11:44 PM, said:

the "public static main (String[] args)" keeps trying to get me to change to "void".

main() should be void but is inside another method

while ((thisLine = () != null); // and NO : there

and I think you have a few } missing at the end of your file

Correctly indented code will show you that main() is in middle of your constructor

import javax.swing.*;
import java.io.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.Color;
import java.awt.Component;
import javax.swing.border.*;
import java.util.*;
import java.awt.*;



public class ATMC extends JFrame  
{


	private static final long serialVersionUID = 1L;
	public static int buttonValue = 0;
	public  boolean dotOn = false;
	public static double amt1 = 0.0f;
	public static JTextArea showArea;
	public JTextField dataField;
	public static JButton disAccBalance;
	public static JButton makeDeposit;
	public static JButton makeWithdraw;
	public static JButton enter,zeroButt, oneButt, twoButt, threeButt, fourButt, fiveButt, sixButt, sevenButt, eightButt, nineButt,dotButt;
	public static boolean customerID = false;
	public static String customerID1 = "";

	@SuppressWarnings("deprecation")
	public void ATMClient( )
	{

		String thisLine;
		final String[] fullText = new String[10];
		String id = " ";
		int counter = 0;

		try
		{
			FileInputStream fis = new FileInputStream("test.dat");
			DataInputStream myInput = new DataInputStream(fis);
			while ((thisLine = () != null)  //  <--- thisLine = () ?????
			{
				System.out.println(thisLine);
				fullText[counter] = thisLine;
				counter++;
			}
		}catch(IOException e){System.out.println("problem");}
		// Create panel p1 for the buttons and set GridLayout
		final JPanel p1 = new JPanel();
		p1.setLayout(new GridLayout(4, 3));
		oneButt = new JButton("1");
		p1.add(oneButt);

		// Handler for "1" button action
		oneButt.addActionListener(new ActionListener()
		{
			public void actionPerformed(ActionEvent e)
			{
				dataField.setText(dataField.getText()+"1");
			}
		});
		twoButt = new JButton("2");
		p1.add(twoButt);
		// Handler for "2" button action
		twoButt.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				dataField.setText(dataField.getText()+"2");


			}
		});
		threeButt = new JButton("3");
		p1.add(threeButt);
		// Handler for "3" button action
		threeButt.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				dataField.setText(dataField.getText()+"3");


			}
		});
		fourButt = new JButton("4");
		p1.add(fourButt);
		// Handler for "4" button action
		fourButt.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				dataField.setText(dataField.getText()+"4");

			}
		});

		fiveButt = new JButton("5");
		p1.add(fiveButt);
		// Handler for "5" button action
		fiveButt.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				dataField.setText(dataField.getText()+"5");

			}
		});
		sixButt = new JButton("6");
		p1.add(sixButt);
		// Handler for "6" button action
		sixButt.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				dataField.setText(dataField.getText()+"6");


			}
		});
		sevenButt = new JButton("7");
		p1.add(sevenButt);
		// Handler for "7" button action
		sevenButt.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				dataField.setText(dataField.getText()+"7");

			}
		});
		eightButt = new JButton("8");
		p1.add(eightButt);
		// Handler for "8" button action
		eightButt.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				dataField.setText(dataField.getText()+"8");


			}
		});
		nineButt = new JButton("9");
		p1.add(nineButt);
		// Handler for "9" button action
		nineButt.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				dataField.setText(dataField.getText()+"9");

			}
		});
		zeroButt = new JButton("0");
		p1.add(zeroButt);
		// Handler for "0" button action
		zeroButt.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				{
					dataField.setText(dataField.getText()+"0");
				}
			}
		});
		dotButt = new JButton(".");
		p1.add(dotButt);
		// Handler for "." button action
		dotButt.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){
				if (dotOn = true)
					dataField.setText(dataField.getText()+".");


			}
		});
		enter = new JButton("ENTER");
		p1.add(enter);
		// Handler for "ENTER" button action
		enter.addActionListener(new ActionListener(){
			public void actionPerformed(ActionEvent e){

				if (disAccBalance.isEnabled())
				{
					if (buttonValue == 1)
					{
						if (dataField.getText() != "")
						{
							String gAmt = dataField.getText();
							amt1 = amt1 + Double.parseDouble(gAmt);
							showArea.setText("");

							showArea.append("TOTAL BALANCE = " +amt1);
						}

					}

					else if (buttonValue == 2)
					{
						if (dataField.getText() != "")
						{
							String gAmt = dataField.getText();
							if (amt1 > Double.parseDouble(gAmt))
							{
								amt1 = amt1 - Double.parseDouble(gAmt);
								showArea.setText("");

								showArea.append("WITHDRAW AMOUNT = " + gAmt + " " + "\nTOTAL BALANCE = " +amt1);
							}
							else {showArea.setText("INSUFFICIENT AMOUNT");}
						}

					}	

					else  {
						for(int i =0; i<fullText.length;i++)
						{

							int chk = 0;
							Scanner scanner = new Scanner(fullText[i]);
							scanner.useDelimiter(" ");
							if ( scanner.hasNext() )
							{

								if(dataField.getText().equals(scanner.next()))
								{
									disAccBalance.setEnabled(true);
									makeDeposit.setEnabled(true);
									makeWithdraw.setEnabled(true);

									dataField.setText("");
									String FirstName = scanner.next();
									showArea.setText("");

									showArea.append("WELCOME\n " + FirstName);

									String SecondName = scanner.next();

									showArea.append(" " +SecondName+"\n");

									String amt = scanner.next();

									amt1 = Double.parseDouble(amt);
									chk = 1;


									break;


								}

							}
							else
							{dataField.setText("");
							// showArea.setText("CUSTOMER-ID NOT FOUND");
							System.out.println("Empty or invalid line. Unable to process.");}

							scanner.close();
							if (chk == 0){showArea.setText("");
							showArea.setText("CUSTOMER-ID NOT FOUND");
							}
						}


					}


				}
				// Create panel p2 to hold a text field and p1
				JPanel p2 = new JPanel(new BorderLayout());

				dataField =new JTextField("",5);
				//dataField.setLineWrap(true);
				// dataField.setWrapStyleWord(true);
				dataField.setEditable(false);
				dataField.setBorder(BorderFactory.createEtchedBorder(1));
				p2.add(dataField,BorderLayout.CENTER);
				JPanel p3 = new JPanel();
				p3.setLayout(new GridLayout(3, 1));

				disAccBalance = new JButton("Display account balance");
				p3.add(disAccBalance);
				// Handler for "display account balance" button action
				disAccBalance.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){
						showArea.setText("");
						showArea.setText("YOUR BALANCE IS = " +amt1);

					}
				});

				makeDeposit = new JButton("Make a deposit");
				p3.add(makeDeposit);
				// Handler for "Make a deposit" button action
				makeDeposit.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){

						showArea.setText("");
						dataField.setText("");
						showArea.setText("           ENTER THE DEPOSIT AMOUNT ");
						buttonValue = 1;
					}
				});

				makeWithdraw = new JButton("Make a withdrawal");
				p3.add(makeWithdraw);
				// Handler for "Make a withdrawal" button action
				makeWithdraw.addActionListener(new ActionListener(){
					public void actionPerformed(ActionEvent e){
						showArea.setText("");
						dataField.setText("");
						showArea.setText("           ENTER THE WITHDRAWAL AMOUNT ");
						buttonValue = 2;

					}
				});

				p2.add(p3, BorderLayout.NORTH);
				p2.add(p1, BorderLayout.SOUTH);

				// Add contents to the frame
				add(p2, BorderLayout.WEST);
				// Text Area for containg output messages
				showArea=new JTextArea("WELCOME! please enter your customer ID into Key pad and press the ENTER button\n", 10, 75);
				showArea.setLineWrap(true);
				showArea.setWrapStyleWord(true);
				showArea.setEditable(false);
				showArea.setBorder(BorderFactory.createBevelBorder(10, Color.lightGray, Color.yellow));
				showArea.setFont(new Font("SansSerif", Font.BOLD,12));
				showArea.setForeground(Color.darkGray);
				add(showArea,BorderLayout.CENTER);

			}


			//Main method
			public static void main(String[] args)
			{
				ATMClient frame = new ATMClient();
				disAccBalance.setEnabled(false);
				makeDeposit.setEnabled(false);
				makeWithdraw.setEnabled(false);
				frame.setTitle("First Bauer Bank ATM");
				frame.setLocationRelativeTo(null); // Center the frame
				frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
				frame.setSize(800, 250);
				frame.setVisible(true);

			}

			private String extracted111(DataInputStream myInput) throws IOException {
				return extracted111(myInput);
			}


			private String extracted11(DataInputStream myInput) throws IOException {
				return extracted(myInput);
			}


			private String extracted(DataInputStream myInput) throws IOException {
				return myInput.readLine();
			}
		}
	}
}


Was This Post Helpful? 0
  • +
  • -

#11 boosh  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 14-January 10

Re: Three Syntax error and i tried everything I know which isn't much

Posted 01 November 2010 - 11:26 PM

View PostHandler, on 01 November 2010 - 09:58 PM, said:

then add the void to
Done That worked after I change it from being a constructor.
Any suggestions on the other issues?
Was This Post Helpful? 0
  • +
  • -

#12 boosh  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 14-January 10

Re: Three Syntax error and i tried everything I know which isn't much

Posted 02 November 2010 - 12:36 AM

Ok I got all the bugs out but one. The middle brace
private String extracted(final DataInputStream myInput) throws IOException {
	return myInput.readLine();
			}
		} <---- Syntax error 
	}
}

Can't figure it out
Was This Post Helpful? 0
  • +
  • -

#13 boosh  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 14-January 10

Re: Three Syntax error and i tried everything I know which isn't much

Posted 02 November 2010 - 06:31 PM

View Postboosh, on 01 November 2010 - 11:36 PM, said:

Ok I got all the bugs out but one. The middle brace
private String extracted(final DataInputStream myInput) throws IOException {
	return myInput.readLine();
			}
		} <---- Syntax error 
	}
}

Can't figure it out

I tried till 4:00am and I got nothing this error keeps popping up any suggestions???
Was This Post Helpful? 0
  • +
  • -

#14 pbl  Icon User is offline

  • There is nothing you can't do with a JTable
  • member icon

Reputation: 8332
  • View blog
  • Posts: 31,857
  • Joined: 06-March 08

Re: Three Syntax error and i tried everything I know which isn't much

Posted 02 November 2010 - 06:55 PM

View Postboosh, on 02 November 2010 - 01:36 AM, said:

Ok I got all the bugs out but one. The middle brace
private String extracted(final DataInputStream myInput) throws IOException {
	return myInput.readLine();
			}
		} <---- Syntax error 
	}
}

Can't figure it out

Depends where you put it. Sure thet the method should look like
private String extracted(final DataInputStream myInput) throws IOException {
	return myInput.readLine();
}



now you have 2 } after
one for closing the class, may be. and than the other one is over

repost your code
Was This Post Helpful? 0
  • +
  • -

#15 boosh  Icon User is offline

  • D.I.C Head

Reputation: 0
  • View blog
  • Posts: 57
  • Joined: 14-January 10

Re: Three Syntax error and i tried everything I know which isn't much

Posted 02 November 2010 - 07:05 PM

View Postpbl, on 02 November 2010 - 05:55 PM, said:

View Postboosh, on 02 November 2010 - 01:36 AM, said:

Ok I got all the bugs out but one. The middle brace
private String extracted(final DataInputStream myInput) throws IOException {
	return myInput.readLine();
			}
		} <---- Syntax error 
	}
}

Can't figure it out

Depends where you put it. Sure thet the method should look like
private String extracted(final DataInputStream myInput) throws IOException {
	return myInput.readLine();
}



now you have 2 } after
one for closing the class, may be. and than the other one is over

repost your code

Here is my re-posted code
import javax.swing.*;
import java.io.*;
import javax.swing.event.*;
import java.awt.event.*;
import java.awt.Color;
import java.awt.Component;
import javax.swing.border.*;
import java.util.*;
import java.awt.*;



public class ATMC extends JFrame  
{
	//Main method
	public static void main(final String[] args)
	{
		final ATMC frame = new ATMC();
		disAccBalance.setEnabled(false);
		makeDeposit.setEnabled(false);
		makeWithdraw.setEnabled(false);
		frame.setTitle("First Bauer Bank ATM");
		frame.setLocationRelativeTo(null); // Center the frame
		frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		frame.setSize(800, 250);
		frame.setVisible(true);

	}
	private static final long serialVersionUID = 1L;
	public static int buttonValue = 0;
	public  boolean dotOn = false;
	public static double amt1 = 0.0f;
	public static JTextArea showArea;
	public JTextField dataField;
	public static JButton disAccBalance;
	public static JButton makeDeposit;
	public static JButton makeWithdraw;
	public static JButton enter,zeroButt, oneButt, twoButt, threeButt, fourButt, fiveButt, sixButt, sevenButt, eightButt, nineButt,dotButt;
	public static boolean customerID = false;
	public static String customerID1 = "";
	

	@SuppressWarnings("deprecation")
	public ATMC( )
	{

		String thisLine;
		final String[] fullText = new String[10];
		final String id = " ";
		int counter = 0;

		try
		{
			final FileInputStream fis = new FileInputStream("test.dat");
			final DataInputStream myInput = new DataInputStream(fis);
			while ((thisLine = id) != null)
			{
				System.out.println(thisLine);
				fullText[counter] = thisLine;
				counter++;
			}
		}catch(final IOException e){System.out.println("problem");}
		// Create panel p1 for the buttons and set GridLayout
		final JPanel p1 = new JPanel();
		p1.setLayout(new GridLayout(4, 3));
		oneButt = new JButton("1");
		p1.add(oneButt);

		// Handler for "1" button action
		oneButt.addActionListener(new ActionListener()
		{
			public void actionPerformed(final ActionEvent e)
			{
				dataField.setText(dataField.getText()+"1");
			}
		});
		twoButt = new JButton("2");
		p1.add(twoButt);
		// Handler for "2" button action
		twoButt.addActionListener(new ActionListener(){
			public void actionPerformed(final ActionEvent e){
				dataField.setText(dataField.getText()+"2");


			}
		});
		threeButt = new JButton("3");
		p1.add(threeButt);
		// Handler for "3" button action
		threeButt.addActionListener(new ActionListener(){
			public void actionPerformed(final ActionEvent e){
				dataField.setText(dataField.getText()+"3");


			}
		});
		fourButt = new JButton("4");
		p1.add(fourButt);
		// Handler for "4" button action
		fourButt.addActionListener(new ActionListener(){
			public void actionPerformed(final ActionEvent e){
				dataField.setText(dataField.getText()+"4");

			}
		});

		fiveButt = new JButton("5");
		p1.add(fiveButt);
		// Handler for "5" button action
		fiveButt.addActionListener(new ActionListener(){
			public void actionPerformed(final ActionEvent e){
				dataField.setText(dataField.getText()+"5");

			}
		});
		sixButt = new JButton("6");
		p1.add(sixButt);
		// Handler for "6" button action
		sixButt.addActionListener(new ActionListener(){
			public void actionPerformed(final ActionEvent e){
				dataField.setText(dataField.getText()+"6");


			}
		});
		sevenButt = new JButton("7");
		p1.add(sevenButt);
		// Handler for "7" button action
		sevenButt.addActionListener(new ActionListener(){
			public void actionPerformed(final ActionEvent e){
				dataField.setText(dataField.getText()+"7");

			}
		});
		eightButt = new JButton("8");
		p1.add(eightButt);
		// Handler for "8" button action
		eightButt.addActionListener(new ActionListener(){
			public void actionPerformed(final ActionEvent e){
				dataField.setText(dataField.getText()+"8");


			}
		});
		nineButt = new JButton("9");
		p1.add(nineButt);
		// Handler for "9" button action
		nineButt.addActionListener(new ActionListener(){
			public void actionPerformed(final ActionEvent e){
				dataField.setText(dataField.getText()+"9");

			}
		});
		zeroButt = new JButton("0");
		p1.add(zeroButt);
		// Handler for "0" button action
		zeroButt.addActionListener(new ActionListener(){
			public void actionPerformed(final ActionEvent e){
				{
					dataField.setText(dataField.getText()+"0");
				}
			}
		});
		dotButt = new JButton(".");
		p1.add(dotButt);
		// Handler for "." button action
		dotButt.addActionListener(new ActionListener(){
			public void actionPerformed(final ActionEvent e){
				if (dotOn = true)
					dataField.setText(dataField.getText()+".");


			}
		});
		enter = new JButton("ENTER");
		p1.add(enter);
		// Handler for "ENTER" button action
		enter.addActionListener(new ActionListener(){
			public void actionPerformed(final ActionEvent e){

				if (disAccBalance.isEnabled())
				{
					if (buttonValue == 1)
					{
						if (dataField.getText() != "")
						{
							final String gAmt = dataField.getText();
							amt1 = amt1 + Double.parseDouble(gAmt);
							showArea.setText("");

							showArea.append("TOTAL BALANCE = " +amt1);
						}

					}

					else if (buttonValue == 2)
					{
						if (dataField.getText() != "")
						{
							final String gAmt = dataField.getText();
							if (amt1 > Double.parseDouble(gAmt))
							{
								amt1 = amt1 - Double.parseDouble(gAmt);
								showArea.setText("");

								showArea.append("WITHDRAW AMOUNT = " + gAmt + " " + "\nTOTAL BALANCE = " +amt1);
							}
							else {showArea.setText("INSUFFICIENT AMOUNT");}
						}

					}	

					else  {
						for(int i =0; i<fullText.length;i++)
						{

							int chk = 0;
							final Scanner scanner = new Scanner(fullText[i]);
							scanner.useDelimiter(" ");
							if ( scanner.hasNext() )
							{

								if(dataField.getText().equals(scanner.next()))
								{
									disAccBalance.setEnabled(true);
									makeDeposit.setEnabled(true);
									makeWithdraw.setEnabled(true);

									dataField.setText("");
									final String FirstName = scanner.next();
									showArea.setText("");

									showArea.append("WELCOME\n " + FirstName);

									final String SecondName = scanner.next();

									showArea.append(" " +SecondName+"\n");

									final String amt = scanner.next();

									amt1 = Double.parseDouble(amt);
									chk = 1;


									break;


								}

							}
							else
							{dataField.setText("");
							// showArea.setText("CUSTOMER-ID NOT FOUND");
							System.out.println("Empty or invalid line. Unable to process.");}

							scanner.close();
							if (chk == 0){showArea.setText("");
							showArea.setText("CUSTOMER-ID NOT FOUND");
							}
						}


					}


				}
				// Create panel p2 to hold a text field and p1
				final JPanel p2 = new JPanel(new BorderLayout());

				dataField =new JTextField("",5);
				//dataField.setLineWrap(true);
				// dataField.setWrapStyleWord(true);
				dataField.setEditable(false);
				dataField.setBorder(BorderFactory.createEtchedBorder(1));
				p2.add(dataField,BorderLayout.CENTER);
				final JPanel p3 = new JPanel();
				p3.setLayout(new GridLayout(3, 1));

				disAccBalance = new JButton("Display account balance");
				p3.add(disAccBalance);
				// Handler for "display account balance" button action
				disAccBalance.addActionListener(new ActionListener(){
					public void actionPerformed(final ActionEvent e){
						showArea.setText("");
						showArea.setText("YOUR BALANCE IS = " +amt1);

					}
				});

				makeDeposit = new JButton("Make a deposit");
				p3.add(makeDeposit);
				// Handler for "Make a deposit" button action
				makeDeposit.addActionListener(new ActionListener(){
					public void actionPerformed(final ActionEvent e){

						showArea.setText("");
						dataField.setText("");
						showArea.setText("           ENTER THE DEPOSIT AMOUNT ");
						buttonValue = 1;
					}
				});

				makeWithdraw = new JButton("Make a withdrawal");
				p3.add(makeWithdraw);
				// Handler for "Make a withdrawal" button action
				makeWithdraw.addActionListener(new ActionListener(){
					public void actionPerformed(final ActionEvent e){
						showArea.setText("");
						dataField.setText("");
						showArea.setText("           ENTER THE WITHDRAWAL AMOUNT ");
						buttonValue = 2;

					}
				});

				p2.add(p3, BorderLayout.NORTH);
				p2.add(p1, BorderLayout.SOUTH);

				// Add contents to the frame
				add(p2, BorderLayout.WEST);
				// Text Area for output messages
				showArea=new JTextArea("WELCOME! please enter your customer ID into Key pad and press the ENTER button\n", 10, 75);
				showArea.setLineWrap(true);
				showArea.setWrapStyleWord(true);
				showArea.setEditable(false);
				showArea.setBorder(BorderFactory.createBevelBorder(10, Color.lightGray, Color.yellow));
				showArea.setFont(new Font("SansSerif", Font.BOLD,12));
				showArea.setForeground(Color.darkGray);
				add(showArea,BorderLayout.CENTER);

			}


			private String extracted111(final DataInputStream myInput) throws IOException {
				return extracted111(myInput);
			}


			private String extracted11(final DataInputStream myInput) throws IOException {
				return extracted(myInput);
			}


			private String extracted(final DataInputStream myInput) throws IOException {
				return myInput.readLine();
			}
		}
	}
}
	


Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2