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 trialJavier MARQUEZ
11,877 PointsI am not so sure of the anwser wanted here. Are we to have int, incrementing like line1 and line2
Here you can see my code for any suggestion thanks
public class ConferenceRegistrationAssistant {
int line1 = 0;
int line2 = 0;
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 */
char firstLetter = lastName.charAt(0);
if (firstLetter >= 'A' & firstLetter <= 'M'){
line = 1;
} else {
line = 2;
}
int line = 0;
return line;
}
}
2 Answers
Shane Robinson
7,324 PointsIt looks like you are just overthinking the problem, here is a valid answer (please try to understand it before using it):
int line = 0;
if (lastName.charAt(0) < 'M') {
line = 1;
} else {
line = 2;
}
return line;
Javier MARQUEZ
11,877 PointsThanks, you are totally right. There was no reason to declare more variables, we can work with the ".chatAt()" method directly. Thank you very much for your help.