Transcribed TextTranscribed Text

Baby Registry! Baby Registry Picking a new name for a baby is an important step in a person's life. Some couples read "baby books" with lists of popular names, while others look online for websites with similar lists. Our goal in this assignment is to create a digital registry of popular names for babies. Input Files You have been given three input files, each of which contains records of baby names given at birth in a US city. Each file is of varying size: baby_names_abbrev.dat: a file containing approximately 30 entries baby_names.dat: a file containing approximately 20,000 entries baby_names_full.dat: a file containing approximately 750,000 entries Each entry in the file has the following format: name, city, state, frequency Given this (fictitious) information you can tell that the baby name was given to a new infant, with a certain frequency, in the given city and state. Assume that this data was gathered over a period of time and then merged into the files you have been given. Your program should work equally well with any of the files located above. Several different data sets are provided to making debugging easier. Program Logic Write a program that reads the data from the files above and allows the user to search through baby names present in the file. Your program should be able to answer the following questions: What baby names were used in a city? What cities used a given baby name? Your program should also store a history of all searches and search results. Searching By City When searching by city, you should prompt the user for a city and state name and then parse through one of the data files above and retrieve all baby names located in that file that were found in that city/state. Your output should also include any outliers. These include the most popular and least popular baby names Below is some sample output: 1. Search City 2. Search Name 3. Exit 1 Enter a city Tacoma Enter a state Washington City search: Tacoma **************** 8 babies named Melany 85 babies named Leslie 60 babies named Wendy 83 babies named Serina 60 babies named Paulita ... Most popular name: Shauna Least popular name: Missy Searching By Baby Name When searching by name, you should prompt the user for a baby name first. Then a list of cities should be displayed where that name was issued to a baby at birth. You should also give a total number of births recorded with the given name. Below is some sample output: 1. Search City 2. Search Name 3. Exit 2 Enter a baby name Lilly Name search: Lilly **************** 82 babies found in Helenville 75 babies found in Sandborn 79 babies found in East Massapequa 6 babies found in Smelterville 8 babies found in Porterville 73 babies found in Miami ... Total babies: 6549 Search History After each choice is made from the menu above, save the output of their results to a file called history.txt. This means that all existing content in the file should not be over-written. Instead, the new input should be appended to the end of the file. To accomplish this, you can pass a true value to the FileOutputStream constructor to open the file in "append-mode." For example: PrintWriter writer = new PrintWriter(new FileOutputStream("history.txt", true)); Here is some example file contents for history.txt. City search: Lakewood **************** 3 babies named Thad 34 babies named Katie 82 babies named Virgil 29 babies named Reid 27 babies named Bulah 15 babies named Annika ... Most popular name: Erica Least popular name: Thad City search: Golden Hill **************** 79 babies named Norman 93 babies named Richie 71 babies named Miguelina 96 babies named Ilse 80 babies named Elvia 73 babies named Dortha ... Most popular name: Zora Least popular name: Rebekah Name search: Gerard **************** 11 babies found in New Boston 49 babies found in Alstead Name search: Terry **************** 33 babies found in Lovingston 44 babies found in Paradise Valley 100 babies found in Woodland Hills ... Requirements This assignment does not strictly define the classes, methods and modules you will need to create to solve this problem. I want to see what you come up with. Each and every one of you is a designer and you are expected to produce a new design to solve this problem. You are free to choose the following: Classes Class fields Class constructors Inheritance relationships Static vs. non-static content Even so, there are some bad choices that can be made here. Adhere to the following rules: You can choose to create the class that runs the menu and reads from files as a static class (all static methods) or you can design separate classes based on key types of functionality (menu/options vs file reading). You should not have overly long methods, called "God methods." Break up your methods into smaller methods. Avoid any redundant code. Don't repeat yourself! Make sure to close all File IO classes that you use. Also, make sure to properly handle all checked exceptions by printing appropriate messages to the console.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

import java.util.*;

* BabyRegistry class
public class BabyRegistry {

// Input file
static String INPUT_FILE = "baby_names_full.dat";
// Output file
static String OUTPUT_FILE = "history.txt";
// Array of baby name records
static ArrayList<BabyNameRecord> records = new ArrayList<BabyNameRecord>();
// Output printwriter
static PrintWriter writer;

   * Method to load input file into records
public static void loadInputFile() throws IOException {
    BufferedReader br = new BufferedReader(new FileReader(INPUT_FILE));
      for(String line; (line = br.readLine()) != null; ) {
      String[] params = line.split(",");
      if (params.length == 4) {
       String name = params[0];
       String city = pa...

By purchasing this solution you'll be able to access the following files:, baby_names.dat, baby_names_full.dat, baby_names_abbrev.dat, history.txt, OUTPUT1.png and OUTPUT2.png.

for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available Java Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Upload a file
Continue without uploading

We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats