• Post Reply Bookmark Topic Watch Topic
  • New Topic

Something in my code is wrong  RSS feed

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hey guys,

i know this question is for many member in this forum too simple to become a answer but please help me. I will start my informatik bachelor in oktobre this year and before that I wanna learn as much as I can about java.

I am working with a book and a task is to write a programm which gives me a songtext out. I tried to make it by myself but something with my "System.out.println()" - commando lines is wrong. I am sure that it's just a little mistake but I cannot find it. I will upload a picture here. I hope someone kind can help me and I am thankfull for every answer I get here.


Regards

Samir H.
Screenshot-(3).png
[Thumbnail for Screenshot-(3).png]
 
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch!
First of all, tell us what is wrong! What do you expect and what do you get. Click this: ItDoesntWorkIsUseless
Second, post your code, not the screenshot. I doubt anyone wants to retype your code into any editor/IDE to check it. Check it: PostTextNotScreenshots
And when you post your code use code tags. Click this: UseCodeTags

BTW, the problem is you didn't put + between wort and string literal.
Also, I suggest you don't learn Java with IDE.
 
Ranch Hand
Posts: 147
Android Eclipse IDE Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
And there are additional plus signs between the brackets and the strings. You only need the operator between to operands, and a bracket is no operand.
 
Samir Hamiani
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Thank you for your response. I thought it is clear what I gonna to try here, sorry. "99 Bierflaschen" is a song. I want that the program gives out the sentence "amount of beer" "bottles" beer is in the fridge., 99 beer bottles etc... After the sentence is over - the program ought repeat the sentence with one bottle less than before and that till there is no beer in the fridge. I cannot compile the .java document to a .class data because the following marked lines are wrong.



I want that my integer value "bierAnzahl = 99" is in the marked line and my string word "Flaschen". I want to reach that the amount of bottles will decrease after each time the loop is over. Please tell me if anything is not clear for you.

Regards

Samir H.
 
Paweł Baczyński
Bartender
Posts: 2087
44
Firefox Browser IntelliJ IDE Java Linux Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Jan Hoppmann wrote:And there are additional plus signs between the brackets and the strings. You only need the operator between to operands, and a bracket is no operand.

Yes, but those + signs don't cause any error.
As bierAnzahl is of type int, + bierAnzahl is just the same as bierAnzahl with no operator.

Samir, I suggest you indent your code properly. It would be easier to read.
See this Code Conventions for the Java Programming Language.
And I believe [b] tags in line 15 and 27 are there just by accident. You can't put [b] tag inside [code] tag.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!