Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

identifier expected - single error

 
Al H
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

I am a first year student and have an issue that I suspect is very simple and hope that someone can help me out!
I am looking to take in a value via a dialogue, parse it to Integer and then validate that it is greater than 600. I am getting one <identifier> expected error on line 21. Help please!!

Here is the code....

 
marc weber
Sheriff
Posts: 11343
Java Mac Safari
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to JavaRanch!

When you define your method, you need to provide an argument type, followed by an identifier name. You are missing the argument type...

public static boolean checkFee( [type?] inFee )
 
Edwin Dalorzo
Ranch Hand
Posts: 961
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
if your declaration

public static boolean checkFee(inFee)

What is the type of the parameter inFee?
 
Ernest Friedman-Hill
author and iconoclast
Marshal
Pie
Posts: 24211
35
Chrome Eclipse IDE Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,

Welcome to JavaRanch!

I couldn't answered this faster if you'd indicated which was line 21; try to do that next time, OK?

It's this line:

public static boolean checkFee( inFee )

You have to specify a data type for the parameter "inFee". In main(), you're passing "inputFee" as the argument, but I think that's an error; you presumably want to check the number, not the String, so I think you want to pass "fee". Then you can change "fee" from being a static member to just being a local variable in main(). Make sense? SO with that change, line 21 would be something like

public static boolean checkFee(int fee )
 
Al H
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thanks Ernest, Edwin and Marc - and yes I will include the line in question in future!

I have made the change as suggested and have a new error message
I assure you that I have spent hours trying to resolve this and other issues today - I am not just taking the easy route. Any thoughts would be thankfully received!


cannot find symbol
symbol : method showMessageDialog(<nulltype>,int,java.lang.String,int)
location: class javax.swing.JOptionPane
JOptionPane.showMessageDialog(null, fee, " Successful Result", JOptionPane.PLAIN_MESSAGE );


The dot between JOptionPane.showMessageDialog is highlighted as being problematic
[ April 27, 2008: Message edited by: Al Hendo ]
 
Roger Chung-Wee
Ranch Hand
Posts: 1683
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You are passing an int instead of an Object into showMessageDialog.

Also, this showMessageDialog method will never run as the checkFee method will already have terminated.
 
Al H
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Guys,
Thanks for your help. I appreciate the feedback but I am still not 100% sure how to fix.

I will follow up with my lecturer.

Cheers
Al
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic