rendered paste body//Sara Drescher
//Assignmet 6A
//Section FH, Candy Chiang
import java.util.*;
import java.io.*;
public class BabyNamesA {
public static final int FIRSTYEAR = 1900;
public static void main (String [] args)
throws FileNotFoundException{
Scanner console = new Scanner(System.in);
Scanner input= new Scanner(new File ("names.txt"));
String s = input.nextLine();
System.out.print ("Type a name (or Enter to quit)? ");
String query = console.next();
search (query, input);
}
public static void search (String query, Scanner input){
String lcquery = query.toLowerCase();
int indicator = 0;
while (input.hasNextLine()) {
String s = input.nextLine();
Scanner lineScan = new Scanner (s);
String name = lineScan.next();
String lcname = name.toLowerCase ();
if (lcname.equals(lcquery)){
results (s);
indicator = 1200;
break;
}
}
if (indicator == 0){
System.out.println ("\"" + query + "\" was not found.");
}
}
public static void results (String s) {
Scanner lineScan2 = new Scanner (s);
System.out.println ("Popularity ranking of the name " + lineScan2.next());
int count = 0;
while (lineScan2.hasNext()) {
System.out.println (1900 + 10*count + ": " + lineScan2.next());
count++;
}
System.out.println(count + " decades worth of date were found.");
}
}