Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Newbie attempt at Method That Returns Non-Numeric Values switch statement  RSS feed

 
Jb Anderson
Greenhorn
Posts: 13
Eclipse IDE Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello Again. To reiterate, I am a newbie attempting to learn Java through iTunes Stanford CS106a and Eric Roberts' "Art and Science of Java." I am not a student nor am I enrolled in any class. I am trying to write out a program that takes numerical input from the user and converts it to a date using the English month name. I am experimenting with the method of a "switch" statement without using the "break" clause. However, I seem to be missing something, as Eclipse is telling me I have a syntax error with my block. My curly braces seem properly placed. So, any feedback would be appreciated. Also, I made sure to follow guidelines to make my code fit on the screen and remain easy to read. Thank you for helping me.


 
Winston Gutkowski
Bartender
Posts: 10575
66
Eclipse IDE Hibernate Ubuntu
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jb Anderson wrote:My curly braces seem properly placed...

They do? They don't to me; and neither does your indenting.

For one thing, your methods don't line up; for seconds: that last println() statement isn't inside any method.

PS: I corrected your code tag placement. Click on the 'Edit' button to see what I did - but don't forget to back out before you do anything else; otherwise you might overwrite your post.

Winston
 
Jb Anderson
Greenhorn
Posts: 13
Eclipse IDE Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hello again, Winston. Thank you again for taking the time to read my post and to provide feedback.

I don't understand what I'm doing wrong when I POST my code to this site--as you could see and as you mentioned-- all my indentation went away and makes me look like a fool! I "copy" the code directly from Eclipse, I click "code" in the JavaRanch window, I "paste" my code in the window, and poof, all my indentation is gone. Thanks for cleaning up the code appearance. Please let me know what I need to do to prevent this from happening in the future.
 
Paul Clapham
Sheriff
Posts: 22835
43
Eclipse IDE Firefox Browser MySQL Database
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jb Anderson wrote:Please let me know what I need to do to prevent this from happening in the future.


After you post the code, select it with the mouse or keyboard and then press the "Code" button which you'll see in that long row of buttons above the box you pasted into.
 
Jb Anderson
Greenhorn
Posts: 13
Eclipse IDE Mac Mac OS X
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Paul,
Ahhhhhhh!! Brilliant. Now I understand I was only clicking the "code" button prior to pasting. Thanks very much for the tutorial! I appreciate your assistance.
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!