All pastes #247298 Raw Edit

Someone

public text v1 · immutable
#247298 ·published 2006-11-13 08:20 UTC
rendered paste body
//Sara Drescher
//Assignmet 6B
//Section FH, Candy Chiang

import java.util.*;
import java.io.*;
import java.awt.*;

public class BabyNamesB {
  
  public static final int FIRSTYEAR = 1900;
  
  public static void main (String [] args)
    throws FileNotFoundException{
    Scanner console = new Scanner(System.in);
    System.out.print ("Type a name (or Enter to quit)? ");
    String query = console.next();
    search (query);
  }
  
  public static void search (String query)
    throws FileNotFoundException{
    Scanner input = new Scanner(new File ("names.txt"));
    String lcquery = query.toLowerCase();
    boolean indicator = true;
    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 = false;
        break;
        
      }
    }
    if (indicator){
      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 data were found.");
    graphicalOutput (count, s);
    
  }
  public static void graphicalOutput (int count, String s){
    Scanner coordinates = new Scanner (s);
    String name = coordinates.next;
    DrawingPanel graph = new DrawingPanel (count*70, 550);
    Graphics pen = graph.getGraphics ();
    pen.setColor (Color.YELLOW);
    pen.fillRect (0, 0, count*70, 25);
    pen.fillRect (0, 525, count*70, 25);
    pen.setColor (Color.BLACK);
    String previousCoord = coordinates.next;
    for (int line = 1; line < count; line++){
      pen.drawLine (70*line, 25, 70*line, 525);
    }
   }
}