aspose file tools*
The moose likes Beginning Java and the fly likes program error Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "program error" Watch "program error" New topic
Author

program error

Stephen Norris
Ranch Hand

Joined: Oct 27, 2003
Posts: 44
When I compile my code for MBAstudent, I get errors saying that it expected 'class' and unexpected type.
Jeanne Boyarsky
internet detective
Marshal

Joined: May 26, 2003
Posts: 29249
    
139

Is the filename the same as the classname? If not, it should be.


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
Stephen Norris
Ranch Hand

Joined: Oct 27, 2003
Posts: 44
Yes, the names are the same. I have to put a check on the input from the Student class in the MBAstudent class, and I don't know how.
Stephen Norris
Ranch Hand

Joined: Oct 27, 2003
Posts: 44
Here is the first part of the program, so what I said earlier will make more sense.
Stephen Norris
Ranch Hand

Joined: Oct 27, 2003
Posts: 44
And here is the second part of my program: MBAstudent
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10
I see a problem in these lines:
public MBAstudent(float gp, int mat)
{
gpa = float gp;
gmat = int mat;
}

You should not be redefining gp or mat at all, much less on the right hand side of an '=' sign.

gpa = gp ;
[ November 12, 2003: Message edited by: Marilyn de Queiroz ]

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9043
    
  10

The if statement must be inside a method. It can't be stuck into the class just anywhere.

Also, you need another curly brace to match the one starting the if block
ln.length>0){
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: program error
 
Similar Threads
possible help, if you have the time ;-(
help with noob java program
Please Help!
can someone help???
Problem with default '' , 0 and 0.0 being inserted into database while using JSTL.