# Tyler Taylor

Greenhorn
since Jul 19, 2015
For More
Cows and Likes
Cows
0
In last 30 days
0
Total given
0
Likes
0
0
Total given
0
Given in last 30 days
0
Scavenger Hunt
Ranch Hand Scavenger Hunt
Greenhorn Scavenger Hunt

## Recent posts by Tyler Taylor

Welcome, R. Singh! We're in this together!
8 years ago
Thank you so much Emil, that really helped me understand.
8 years ago
LOL oh wow, the answer was a few pages after the exercise, so I feel dumb for posting. But I'm still not entirely sure what changed the last hyphen. Maybe someone could explain it in cavemen terms for me?

I moved the x = x - 1 and print up, then added another x = x - 1 to the last if statement. Why is that necessary after the first one?

Here is the correct code:
8 years ago
First of all, hello everybody! I have recently gotten the programming itch. In googling questions, this site popped up a bunch so I figured I might as well join.

Take it easy on me, I am a complete greenhorn!

Okay so I just got to the first exercise of Head First Java, and I'm slightly confused by the output I'm getting. They give you snippets of code that are supposed to be magnets on a fridge, out of order, and you have to put them in order. Pretty simple!

It SHOULD be "a-b c-d", but I am getting "a-b c-d-" and can't figure out how to get rid of the last hyphen.

It is probably very obvious haha but my newb eyes can't see it. If x is equal to 1, it prints "d"; but the while loop is x greater than 0, so since D/1 is still > 0 it's printing the hyphen at the end? Am I right in that?

Thanks for any help! Hopefully soon I can contribute and help too.

Here's the code:
8 years ago