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 Creating the MVP Conference Registration Assistant

Bin Chen
Bin Chen
627 Points

Hi everyone, was wondering if someone could share what they had for the ConferenceforRegistration challenge? Thanks!

Wanted to compare what I had to what someone else may have had

1 Answer

Fahad Mutair
Fahad Mutair
10,359 Points

here's some ways to solve this challenge

public int getLineNumberFor(String lastName) {
      char firstLetter = lastName.charAt(0);
      return (firstLetter >= 'A' && firstLetter <= 'M') ? 1 : 2;
  }
public int getLineNumberFor(String lastName) {
    int lineNumber = 0;
    if ('A' <= lastName.charAt(0) && lastName.charAt(0) <= 'M') {
        lineNumber = 1;
      }
      if ('N' <= lastName.charAt(0) && lastName.charAt(0) <= 'Z') {
        lineNumber = 2;
      }
    return lineNumber;
  }
public int getLineNumberFor(String lastName) {
    int lineNumber = 0;
    if(lastName.charAt(0) > 'M'){
        lineNumber = 2;
      } else {
        lineNumber = 1;
      } 
    return lineNumber;
  }
public int getLineNumberFor(String lastName) {
    int lineNumber;
    String alphabet = "ABCDEFGHIJKLM";
    char firstLetter = lastName.charAt(0);
    if(alphabet.indexOf(firstLetter) != -1){
    lineNumber = 1;
    }else{
    lineNumber = 2;}
    return lineNumber;
  }