Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trialNoah Schill
10,020 PointsWon't return?
Won't return line 1. Is is supposed to be a string, even though it is originally declared as a variable?
public class ConferenceRegistrationAssistant {
public int getLineFor(String lastName) {
/* If the last name is between A thru M send them to line 1
Otherwise send them to line 2 */
int line = 0;
if (lastName.charAt(0) >= 'm') {
line = ;
} else {
line = 2;
}
return line;
}
}
2 Answers
Lee Reynolds Jr.
5,160 PointsI just put this code in and it worked fine for the challenge. I hope that I didn't run you in too many circles trying to help.
public class ConferenceRegistrationAssistant {
public int getLineFor(String lastName) { /* If the last name is between A thru M send them to line 1 Otherwise send them to line 2 */ int line = 0; if (lastName.charAt(0) < 'N') { line = 1;
} else {
line = 2;
}
return line;
}
}
Happy Coding:)
Lee Reynolds Jr.
5,160 PointsYou have nothing for it to return in the first part. You have line = ; Try using line = 1;
Noah Schill
10,020 PointsI fixed that error, but it still wont return a line.
Lee Reynolds Jr.
5,160 PointsYou didn't add anything to tell the person what line they're going to be in. Try This(modify it to fit the specifications of the challenge needing you to print to the screen):
public class ConferenceRegistrationAssistant {
public int getLineFor(String lastName) { /* If the last name is between A thru M send them to line 1 Otherwise send them to line 2 */ int line = 0; if (lastName.charAt(0) >= 'm') { line = ; System.out.println("You are in line 1."); } else { line = 2; System.out.println("You are in line 2."); }
return line;
}
}
Happy Coding :)
Lee Reynolds Jr.
5,160 PointsI'm about to go look at the challenge myself so that I can see what exactly it is asking for.
Noah Schill
10,020 PointsI tried that as well, but unfortunately didn't pass the challenge. :/
Lee Reynolds Jr.
5,160 Pointshaha oh my goodness. I feel so silly now. I see what the issue was. You are comparing it in the opposite direction than you should be. You're asking it in the first if statement if the first letter is greater than or equal to M. Swap the sign around to less than.
Noah Schill
10,020 PointsNoah Schill
10,020 PointsThank you so much Lee! Worked like a charm!