Win a copy of Programmer's Guide to Java SE 8 Oracle Certified Associate (OCA) this week in the OCAJP forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

program error

 
Stephen Norris
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
When I compile my code for MBAstudent, I get errors saying that it expected 'class' and unexpected type.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34837
369
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Is the filename the same as the classname? If not, it should be.
 
Stephen Norris
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Here is the first part of the program, so what I said earlier will make more sense.
 
Stephen Norris
Ranch Hand
Posts: 44
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And here is the second part of my program: MBAstudent
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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 ]
 
Marilyn de Queiroz
Sheriff
Posts: 9066
12
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

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){
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic