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 trialjrmieblais
12,492 PointsI'm lost.
I don't understand the question, do I ?
3 Answers
jason phillips
18,131 Points/* If the last name is between A thru M send them to line 1
Otherwise send them to line 2 */
You need to write an if statement so if the first letter of the lastname is a through m you would set the line variable to 1 otherwise 2
jrmieblais
12,492 Pointspublic class ConferenceRegistrationAssistant {
public int getLineFor(String lastName) {
int line = 0;
return line;
if ( lastName.charAt(0) >= 'A' && lastName.charAt(0) =< 'M' ) {
line = 1;
} else {
line = 2;
}
return line;
}
}
That's what I did...
jrmieblais
12,492 Pointspublic 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;
return line;
char a = lastName.charAt(0);
if ( a >= 'A' && a < 'M' ) {
line = 1;
} else if ( a > 'M' && a >= 'Z') {
line = 2;
}
return line;
}
}
jrmieblais
12,492 PointsDoes not work... what am I doing wrong ?
jason phillips
18,131 PointsYou have 2 return line;
lines. You need to remove the first one directly after you set the line variable to 0.
int line = 0;
return line;
char a = lastName.charAt(0);
if ( a >= 'A' && a < 'M' ) {
line = 1;
} else if ( a > 'M' && a >= 'Z') {
line = 2;
}
return line;
becomes
int line = 0;
char a = lastName.charAt(0);
if ( a >= 'A' && a < 'M' ) {
line = 1;
} else if ( a > 'M' && a >= 'Z') {
line = 2;
}
return line;