Quote (Lightro @ Nov 10 2014 08:56pm)
Taking intro to java course and need help.
i need to write a method to search for and return a line to main from a txt file.
ex: of lines
Jax M 0 0 0 0 0 0 0 0 0 0 0 0 0 347
Randall M 731 974 620 650 467 369 232 70 59 100 136 192 440 841
User input :
name ? _________
gender ? ________
sample code from my program...
System.out.print("name? ");
String name = console.next().toLowerCase();
System.out.print("gender (M or F)? ");
String gender = console.next().toLowerCase();
while (input.hasNextLine()) {
String line = input.nextLine();
if ( ) {
return line;
}
i cant get it to work. any tips would be appreciated...
Scanner input = new Scanner(filePath);
System.out.println("Name?");
String name = input.nextLine();
System.out.println("Gender (M or F)?: ");
String gender = input.nextLine();
//This is for testing
System.out.println("The name is: " + name + " and the gender is: " + gender);
Is that essentially the answer you got?