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

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

Organizing the lines......

Once again, I have written some code. Also, once again, my code passes through the testing but will not pass through the example. I have tried the code that is copied below for me. I have also tried the code as follows.

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; String organize = console.readLine("Enter last name: "); char whichLine = organize.charAt(0); if(whichLine < N){ int line = 1; }else{ int line = 2; } return line; }

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;
    String organize = console.readLine("Enter last name:  ");
    char whichLine = organize.charAt(0);
    if(whichLine < N){
      System.out.println("You are in Line 1.");
    }else{
      System.out.println("You are in Line 2");
    }
    return line;
  }

}

2 Answers

Craig Dennis
STAFF
Craig Dennis
Treehouse Teacher

You should use the lastName variable passed into the method. No need to prompt in here ;) Also, as Ivan said wrap your check in single quotes.

Ivan Sued
Ivan Sued
5,969 Points

The error seems to be in the if statement. The comparison you want is with 'N' char not a N var. If you do not put quotes the compiler will try to find a variable that has the name of N not the char of 'N'.