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

Bob Allan
Bob Allan
10,900 Points

Registration Assistant - 2 hours of effort... where have I gone wrong?

My brain hurts and I'm crosseyed from working on this. I feel like I'm close. Could you please help me with the finishing touches? What am I missing?

ConferenceRegistrationAssistant.java
import java.util.Scanner;

public class ConferenceRegistrationAssistant {

  public int getLineNumberFor(String lastName) {

    int lineNumber = 0;

    public promptForLastName() {

    Scanner scanner = new Scanner(System.in);
    System.out.print("Enter your last name:   ");
    String lastName = scanner.nextLine();
    char lastInitial = lastInitial.charAt(0);

    if (lastInitial > 'N') {
      lineNumber = 1;
    } else {
      lineNumber = 2;
    }
    return lineNumber;
    }

}
Example.java
public class Example {

  public static void main(String[] args) {

    ConferenceRegistrationAssistant assistant = new ConferenceRegistrationAssistant();

    lineNumber = assistant.getLineNumberFor("Zimmerman");
    lineNumber = assistant.getLineNumberFor("Anderson");
    lineNumber = assistant.getLineNumberFor("Brown");
  }
}

3 Answers

Bob Allan
Bob Allan
10,900 Points

Nevermind, I figured it out. I just needed 2.5 hours I guess. ;-)

Pieter-Andries van der Berg
Pieter-Andries van der Berg
7,468 Points

Can you also share the result so that others also can see how you figured it out?

Heather Malloch
Heather Malloch
2,141 Points

This is the answer I got:

 public int getLineNumberFor(String lastName) {
    int lineNumber = 0;
    if (lastName.charAt(0) <= 'M') {
      lineNumber = 1;
    } else {lineNumber = 2;
     }