• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Having problem compiling this answer

 
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
This is what it says after i compile the program

class, interface, or enum expected
}
^
1 error


 
Ranch Hand
Posts: 152
VI Editor Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

it's all in the format



count them curly brackets (open & close), and notice the last line in the reformatted listing

good luck at the tables
M
 
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You should better format your code... it really looks unbalanced. Let me check....




Yup... you have a few extra close braces.

[EDIT: wow. I got beat by 8 seconds.]

Henry
 
Nick Hallloran
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
ok so i deleted to of the braces..but now all it says is what i rolled...not if i win or lose.... I thought my code was correct...but somewhere im going wrong and i cant find it
 
Henry Wong
author
Posts: 23951
142
jQuery Eclipse IDE Firefox Browser VI Editor C++ Chrome Java Linux Windows
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Nick Hallloran wrote:...but now all it says is what i rolled...not if i win or lose....



If you start with the main(), and follow what is it doing, you should quickly figure out why. After all, the main() method is only 5 lines long.

Henry
 
Nick Hallloran
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I was thinking maybe because i put a closed brace at the end of the main method..but i removed it and added on at the very end and that didnt work either.
 
Marshal
Posts: 79153
377
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You ought to be indenting your code correctly; that will make it easy to see where your {} are matched and where they aren't.
 
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@Nick Hallloran

First of all, you should have a good programing style because of which the code becomes more manageable and eligible.
I saw your code and then, you have two more ending braces than required. Its generally that newbies have habit of opening bracket, then write the code and in the end close it. This can lead to syntax errors and hours of headaches to find the problem.
A simple solution to this is ,once you open a bracket, close it straight away and then start writing the code within the brackets.

Always use proper indentations.
Make sure you write as many comments as you can that will help others to identify how a variable or method behaves and reduces the difficulty of understanding the code.

For now here is the code syntax error free code.


Also last but not the least, make sure you change the habit of naming methods.
for more info, google for programing standards, choose a style which suites you.
 
Nick Hallloran
Greenhorn
Posts: 19
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
yea i can get it to compile now no problem..but my problem is that when i execute the program all it says is what i rolled not if i won or lost.
 
Ashish Schottky
Ranch Hand
Posts: 93
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
@nick

Well take a proper look at the program.
You have written a method,but you are not invoking it.
I have not tried this, but for sure you are not invoking it in this program.

 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic