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 trial

Java Java Objects (Retired) Creating the MVP Comparing Characters

Noah Schill
Noah Schill
10,020 Points

Won't return?

Won't return line 1. Is is supposed to be a string, even though it is originally declared as a variable?

ConferenceRegistrationAssistant.java
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.
Lee Reynolds Jr.
5,160 Points

I 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:)

Noah Schill
Noah Schill
10,020 Points

Thank you so much Lee! Worked like a charm!

Lee Reynolds Jr.
Lee Reynolds Jr.
5,160 Points

You have nothing for it to return in the first part. You have line = ; Try using line = 1;

Noah Schill
Noah Schill
10,020 Points

I fixed that error, but it still wont return a line.

Lee Reynolds Jr.
Lee Reynolds Jr.
5,160 Points

You 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.
Lee Reynolds Jr.
5,160 Points

I'm about to go look at the challenge myself so that I can see what exactly it is asking for.

Noah Schill
Noah Schill
10,020 Points

I tried that as well, but unfortunately didn't pass the challenge. :/

Lee Reynolds Jr.
Lee Reynolds Jr.
5,160 Points

haha 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.