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 trialBob Allan
10,900 PointsRegistration 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?
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;
}
}
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
10,900 PointsNevermind, I figured it out. I just needed 2.5 hours I guess. ;-)
Pieter-Andries van der Berg
7,468 PointsCan you also share the result so that others also can see how you figured it out?
Heather Malloch
2,141 PointsThis is the answer I got:
public int getLineNumberFor(String lastName) {
int lineNumber = 0;
if (lastName.charAt(0) <= 'M') {
lineNumber = 1;
} else {lineNumber = 2;
}