Question: Write a program that reads in worked_example_1/babynames.txt and produces two files, boynames.txt and girlnames.txt , separating the data for the boys and girls. Below is
Write a program that reads in worked_example_1/babynames.txt and produces two files, boynames.txt and girlnames.txt, separating the data for the boys and girls. Below is the code to start with:
PS: need the Java code and uses eclipse, and this is the link to the text file http://txt.do/dxs1g
---------------------------------------------------------------------------------------------------------------------------------------------------
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.util.Scanner;
/**
* Code for P11.1. This program takes in a list of baby names and outputs a list of boys and
girls names.
* @author
*/
public class BabyNames
{
// In this method, you do not need to ask user the filename through arguments of the main method or console.
public static void main(String[] args)
{
try (Scanner in = new Scanner(new File("babynames.txt"));
PrintWriter boyOut = new PrintWriter("boynames.txt");
PrintWriter girlOut = new PrintWriter("girlnames.txt"))
{
// Your work starts here
}
catch (IOException e)
{
e.printStackTrace();
}
}
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
