• Post Reply Bookmark Topic Watch Topic
  • New Topic

Nube java problem  RSS feed

 
Steve Champion
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I am trying to compile this and I keep getting 17 errors...
can anyone help me??
I don't see what im doing wrong...
Thanks
Steve




 
Barry Burd
Author
Ranch Hand
Posts: 133
10
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Did you remember to import java.util.Scanner? That's the only thing I see when I try to compile the code.
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And if Barry's guess wasn't right, you could continue by telling us what the error messages say. They are there to provide information, you know, not just to tell you that you did something wrong.
 
Paul Clapham
Sheriff
Posts: 22819
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And also, welcome to the Ranch!
 
Steve Champion
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Barry Burd wrote:Did you remember to import java.util.Scanner? That's the only thing I see when I try to compile the code.


Hi Barry, yes I did, just didn't copy that part because the error wasn't there.

Thanks for the thought though!!
 
Barry Burd
Author
Ranch Hand
Posts: 133
10
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see any error messages when I import it into Eclipse. Can you copy/paste the error messages and show where they appear?
 
Steve Champion
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The first error says:

Chap8Part5.java:12: error: ')' expected
letterGrade = "A";
^

others are similar...
 
Steve Champion
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

C:\Users\steve\Documents\java>javac Chap8Part5.java
Chap8Part5.java:12: error: ')' expected
letterGrade = "A";
^
Chap8Part5.java:11: error: not a statement
if (grade >= 90) (
^
Chap8Part5.java:13: error: illegal start of expression
) else if (grade >= 80) (
^
Chap8Part5.java:13: error: 'else' without 'if'
) else if (grade >= 80) (
^
Chap8Part5.java:13: error: not a statement
) else if (grade >= 80) (
^
Chap8Part5.java:15: error: illegal start of expression
) else if (grade >= 70) (
^
Chap8Part5.java:15: error: 'else' without 'if'
) else if (grade >= 70) (
^
Chap8Part5.java:15: error: not a statement
) else if (grade >= 70) (
^
Chap8Part5.java:17: error: illegal start of expression
) else if (grade >= 60) (
^
Chap8Part5.java:17: error: 'else' without 'if'
) else if (grade >= 60) (
^
Chap8Part5.java:17: error: not a statement
) else if (grade >= 60) (
^
Chap8Part5.java:19: error: illegal start of expression
) else if (grade >= 0) (
^
Chap8Part5.java:19: error: 'else' without 'if'
) else if (grade >= 0) (
^
Chap8Part5.java:19: error: not a statement
) else if (grade >= 0) (
^
Chap8Part5.java:21: error: illegal start of expression
) else
^
Chap8Part5.java:21: error: 'else' without 'if'
) else
^
Chap8Part5.java:27: error: class, interface, or enum expected
}
^
17 errors
 
Barry Burd
Author
Ranch Hand
Posts: 133
10
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't see that error when I paste the code into Eclipse. Maybe you can attach a screenshot showing the code on your screen and the error(s)?
 
Barry Burd
Author
Ranch Hand
Posts: 133
10
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
It looks like you're using parentheses in places where you should be using curly braces. But why the code that I pasted into Eclipse had curly braces, I don't know.
 
Barry Burd
Author
Ranch Hand
Posts: 133
10
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
 
Steve Champion
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Barry Burd wrote:It looks like you're using parentheses in places where you should be using curly braces. But why the code that I pasted into Eclipse had curly braces, I don't know.


I know that is the same thing I'm seeing. I'm putting in the curly and compile is seeing regular parentheses...
 
Barry Burd
Author
Ranch Hand
Posts: 133
10
Android Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Very strange! I think some screenshots (if you can attach them) would help me figure out what's going on.
 
Steve Champion
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I figured it out!! What I was doing was compiling a previous version....
Thanks for the help... If you hadn't shown me the Eclipse I wouldn't have thought about it for a while!!
Thanks!!
Steve
 
Campbell Ritchie
Marshal
Posts: 56525
172
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If there is a first error like ) expected, that will throw all the rest of the code out of synch. You may find that correcting the first error will cause several others to go away.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!