0

Ok im exhausted and just want to go to bed and this has been frustrating me for the last 45 minutes. This method needs to include a check for a 10 digit number from the acctNum and then parseInt but im just brain locked as to where to even put the acctNum.getText().length statement. Ive commented out what im trying to add. Can someone point me in the right direction, please I dont want someone to give me the direct answer but just some guidance. Ive tried placing it in other parts but give me alot more error when trying to compile. This is currently only giving me 6 errors.

BillPayer.java:200: error: illegal start of expression
if (acctNum.getText().length() != 10)
^
BillPayer.java:200: error: not a statement
if (acctNum.getText().length() != 10)
^
BillPayer.java:200: error: ';' expected
if (acctNum.getText().length() != 10)
^
BillPayer.java:213: error: not a statement
(state.getText().compareTo("")<1) ||
^
BillPayer.java:214: error: ';' expected
(zip.getText().compareTo("")<1) )
^
BillPayer.java:220: error: 'else' without 'if'
else
^
6 errors

public boolean checkFields()
{
	if ((acctNum.getText().compareTo("")<1)	||
		(acctNum.getText().length() !=10)		|| 
			/*	if (acctNum.getText().length() != 10)
		{
			JOptionPane.showMessageDialog(null, "You must enter a 10 digit number.", "Data Entry Error", JOptionPane.WARNING_MESSAGE);
			acctNum.requestFocusInWindow();
			return false;
		} */
																
																	 
		 (pmt.getText().compareTo("")<1)			||
		 (firstName.getText().compareTo("")<1) ||
		 (lastName.getText().compareTo("")<1) 	||
		 (address.getText().compareTo("")<1)	||
		 (city.getText().compareTo("")<1)		||
		 (state.getText().compareTo("")<1)		||
		 (zip.getText().compareTo("")<1)	)	
		 				
	{
		JOptionPane.showMessageDialog(null,"YOu must complete all fields.","Data entry error",JOptionPane.WARNING_MESSAGE);
		return false;
	}
		else
	{
		return true;
	}
}

Edited by neemo6: n/a

2
Contributors
1
Reply
2
Views
6 Years
Discussion Span
Last Post by Taywin
1

If you want only the specifically check only acctNum.getText().length()!=10, you could take the if out and use if-elseif-else statement instead of use only if-else statement. :)

if (...) {  // check for the length
}
else if ( ... ) {  // the rest of checking
}
else {  // whatever left over
}

Edited by Taywin: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.