Error Message

Illegal start of expression

Page 1 of 1

13 Replies - 842 Views - Last Post: 29 May 2009 - 10:30 PM Rate Topic: -----

#1 Javabeginner_1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-May 09

Error Message

Posted 29 May 2009 - 09:23 PM

I keep getting illegal start of expression or not a statement error on this code. What am I doing wrong or missing?
  private void displayBillJButtonActionPerformed(java.awt.event.ActionEvent evt) {												   
			
			   
			// display error message if no name entered or no box selected
		if ( ( petNameJTextField.getText().equals( "" ) ) ||
		   (!tcJCheckBox.isSelected() && 
		   !rbJCheckBox.isSelected() &&
		   !osJCheckBox.isSelected() && 
		   !hwJCheckBox.isSelected() &&
		   !fcJCheckBox.isSelected() &&
		   !ftJCheckBox.isSelected() &&
		   !ovJCheckBox.isSelected() &&
		   !otJCheckBox.isSelected() ) 
		 )
	  {
		 // display error message
		 JOptionPane.showMessageDialog( null,
			"Please enter pet's name and select at least one service.",
			"Missing information", JOptionPane.WARNING_MESSAGE );
	  }
			
			else //  do calculations
			double procedure = 0;
			double total = 0;
			double tax = 0;
			double amount;
			tax = 0.088 * procedure;
			total = procedure + tax;

			StringBuffer display = new StringBuffer("");
			{
			 display.append(padSpaces("Code"\t "Procedure",\t "Fee" +  "\n");
			 display.append("-----------------------------------------" + "\n");
			 display.append(padSpaces(Code)\t procedureName(tax))" + "\n");
			 display.append("-----------------------------------------" + "\n");
			 display.append(padSpaces("Tax", dollarsFormatting.format(tax)) + "\n");
			 display.append(padSpaces("Total", dollarsFormatting.format(total)));
			 invoiceJTextArea.setText(display.toString());
		}

			  private StringBuffer padSpaces(String first, String second)
	{
	   final int maximumSpaces = 40;
	   StringBuffer spaces = new StringBuffer(first);
	   int numSpaces = maximumSpaces - first.length() - second.length();
	   for (int i = 0; i < numSpaces; i++)
		   spaces.append(" ");
	   spaces.append(second);
	   return spaces;



Is This A Good Question/Topic? 0
  • +

Replies To: Error Message

#2 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Error Message

Posted 29 May 2009 - 09:30 PM

Which line of code are you getting the error at?
Was This Post Helpful? 0
  • +
  • -

#3 Javabeginner_1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-May 09

Re: Error Message

Posted 29 May 2009 - 09:34 PM

View PostJavabeginner_1, on 29 May, 2009 - 08:23 PM, said:

I keep getting illegal start of expression or not a statement error on this code. What am I doing wrong or missing?
  private void displayBillJButtonActionPerformed(java.awt.event.ActionEvent evt) {												   
			
			   
			// display error message if no name entered or no box selected
		if ( ( petNameJTextField.getText().equals( "" ) ) ||
		   (!tcJCheckBox.isSelected() && 
		   !rbJCheckBox.isSelected() &&
		   !osJCheckBox.isSelected() && 
		   !hwJCheckBox.isSelected() &&
		   !fcJCheckBox.isSelected() &&
		   !ftJCheckBox.isSelected() &&
		   !ovJCheckBox.isSelected() &&
		   !otJCheckBox.isSelected() ) 
		 )
	  {
		 // display error message
		 JOptionPane.showMessageDialog( null,
			"Please enter pet's name and select at least one service.",
			"Missing information", JOptionPane.WARNING_MESSAGE );
	  }
			
			else //  do calculations
			double procedure = 0;
			double total = 0;
			double tax = 0;
			double amount;
			tax = 0.088 * procedure;
			total = procedure + tax;

			StringBuffer display = new StringBuffer("");
			{
			 display.append(padSpaces("Code"\t "Procedure",\t "Fee" +  "\n");
			 display.append("-----------------------------------------" + "\n");
			 display.append(padSpaces(Code)\t procedureName(tax))" + "\n");
			 display.append("-----------------------------------------" + "\n");
			 display.append(padSpaces("Tax", dollarsFormatting.format(tax)) + "\n");
			 display.append(padSpaces("Total", dollarsFormatting.format(total)));
			 invoiceJTextArea.setText(display.toString());
		}

			  private StringBuffer padSpaces(String first, String second)
	{
	   final int maximumSpaces = 40;
	   StringBuffer spaces = new StringBuffer(first);
	   int numSpaces = maximumSpaces - first.length() - second.length();
	   for (int i = 0; i < numSpaces; i++)
		   spaces.append(" ");
	   spaces.append(second);
	   return spaces;


the error for illegal start is at line 632 "}"; and the not a statement is lines 624 & 626 of the string buffer
Was This Post Helpful? 0
  • +
  • -

#4 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Error Message

Posted 29 May 2009 - 09:40 PM

I dont believe you can return a buffer, so have you tried to return a string?
Check your braces, you have misplaced one
Was This Post Helpful? 0
  • +
  • -

#5 Javabeginner_1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-May 09

Re: Error Message

Posted 29 May 2009 - 09:42 PM

View PostFuzzyness, on 29 May, 2009 - 08:40 PM, said:

I dont believe you can return a buffer, so have you tried to return a string?
Check your braces, you have misplaced one

I actually used the buffer from another assignment I did and it worked then and I'll try to see where the missing brace is
Was This Post Helpful? 0
  • +
  • -

#6 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Error Message

Posted 29 May 2009 - 09:45 PM

Yeah just thought about it and yeah it should work. I think once you fix the brace problem it should work. that can throw off commands sometimes.

I cant see your line numbers, so can you copy and paste the 3 lines the error affects? sorry
Was This Post Helpful? 0
  • +
  • -

#7 Javabeginner_1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-May 09

Re: Error Message

Posted 29 May 2009 - 09:52 PM

View PostFuzzyness, on 29 May, 2009 - 08:45 PM, said:

Yeah just thought about it and yeah it should work. I think once you fix the brace problem it should work. that can throw off commands sometimes.

I cant see your line numbers, so can you copy and paste the 3 lines the error affects? sorry

No problem, the braces error is fixed but still having issues with:
  display.append(padSpaces("Code"\t "Procedure",\t "Fee" +  "\n");
display.append(padSpaces(Code)\t procedureName(tax))" + "\n");
display.append(padSpaces("Total", dollarsFormatting.format(total)));



thanks for your help
Was This Post Helpful? 0
  • +
  • -

#8 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Error Message

Posted 29 May 2009 - 10:02 PM

For the first two lines you need to put the tab command in + and parentheses
+ "\n" +
as for the second line, you have the append method closed before the line is finished
(padSpaces(Code)\t procedureName(tax))"
'(' before pad opens it, code opens and closes, tax opens and 2 closing. Thus closing the appends but you still have other Strings trying to be added.

Have you tried for the third line doing "Totoal" + dollarsFormatting.format(total)); Not sure on third one really havent used append before.

An alternative to using append you may be able to use
display.setTexts(display.getTexts() + "All other Strings ect");
Was This Post Helpful? 0
  • +
  • -

#9 Javabeginner_1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-May 09

Re: Error Message

Posted 29 May 2009 - 10:08 PM

View PostFuzzyness, on 29 May, 2009 - 09:02 PM, said:

For the first two lines you need to put the tab command in + and parentheses
+ "\n" +
as for the second line, you have the append method closed before the line is finished
(padSpaces(Code)\t procedureName(tax))"
'(' before pad opens it, code opens and closes, tax opens and 2 closing. Thus closing the appends but you still have other Strings trying to be added.

Have you tried for the third line doing "Totoal" + dollarsFormatting.format(total)); Not sure on third one really havent used append before.

An alternative to using append you may be able to use
display.setTexts(display.getTexts() + "All other Strings ect");

ok, I fixed the bottom two; I forgot to use decimal format
as far as the 1st line I' check the tab command

  display.append(padSpaces("Code", \t "Procedure" \t "Fee" +  "\n");


Thanks again
Was This Post Helpful? 0
  • +
  • -

#10 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Error Message

Posted 29 May 2009 - 10:11 PM

display.append(padSpaces("Code", "\tProcedure" + "\tFee\n");
That what you looking for?
Was This Post Helpful? 0
  • +
  • -

#11 Javabeginner_1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-May 09

Re: Error Message

Posted 29 May 2009 - 10:21 PM

View PostFuzzyness, on 29 May, 2009 - 09:11 PM, said:

display.append(padSpaces("Code", "\tProcedure" + "\tFee\n");
That what you looking for?

No, that didn't work either thanks again for you help
Was This Post Helpful? 0
  • +
  • -

#12 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Error Message

Posted 29 May 2009 - 10:25 PM

Yeah, well that was missing a second closing parentheses which im sure you caught hmm... What is padspcaes btw? I havent been able to see a variable for it anywhere. What is it an object of?
Was This Post Helpful? 0
  • +
  • -

#13 Javabeginner_1  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 11
  • Joined: 19-May 09

Re: Error Message

Posted 29 May 2009 - 10:27 PM

View PostFuzzyness, on 29 May, 2009 - 09:25 PM, said:

Yeah, well that was missing a second closing parentheses which im sure you caught hmm... What is padspcaes btw? I havent been able to see a variable for it anywhere. What is it an object of?

got it was the miss )
Was This Post Helpful? 0
  • +
  • -

#14 Fuzzyness  Icon User is offline

  • Comp Sci Student
  • member icon

Reputation: 669
  • View blog
  • Posts: 2,438
  • Joined: 06-March 09

Re: Error Message

Posted 29 May 2009 - 10:30 PM

haha, ok cool. Glad it works now :)
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1