Question: Write an application called BabyNames1900sAnd2000s to print two columns in alphabetical order. The first column will contain all the boys names for 1900s that were

Write an application called BabyNames1900sAnd2000s to print two columns in alphabetical order. The first column will contain all the boys names for 1900s that were still popular in 2000s. The second column will contain all the girls names for 1900s that were still popular in 2000s. Make the columns 30 characters wide and left justified.

There are two files:

http://www.laughton.com/obrien/sjsu/cs49j/files/babynames1900s.txt

http://www.laughton.com/obrien/sjsu/cs49j/files/babynames2000s.txt

This is my code:

And, my result has some problem, I can't find out.

You can change my code, but I hope don't change my idea.

//**************************************************

import java.io.File; import java.io.FileNotFoundException; import java.net.URL; import java.util.ArrayList; import java.util.Collections; import java.util.Scanner;

public class BabyNames1900sAnd2000s { public static void main(String[] args) throws FileNotFoundException{ URL pageLocation1 = new URL("http://www.laughton.com/obrien/sjsu/cs49j/files/babynames1900s.txt"); URL pageLocation2 = new URL("http://www.laughton.com/obrien/sjsu/cs49j/files/babynames2000s.txt"); Scanner scan1 = new Scanner(pageLocation1.openStream()); Scanner scan2 = new Scanner(pageLocation2.openStream()); /*if (args.length

ArrayList boys1900 = new ArrayList(); ArrayList girls1900 = new ArrayList();

ArrayList boys2000 = new ArrayList(); ArrayList girls2000 = new ArrayList();

ArrayList boysPopular = new ArrayList(); ArrayList girlsPopular = new ArrayList();

while(scan1.hasNextLine() && scan2.hasNextLine()) { String line1 = scan1.nextLine(); String line2 = scan2.nextLine(); String [] description1 = line1.split("\\s+"); String [] description2 = line1.split("\\s+");

boys1900.add(description1[1]); boys2000.add(description2[1]);

girls1900.add(description1[3]); girls2000.add(description2[3]); }

scan1.close(); scan2.close();

for(int i=0; i

for(int i=0; i

printPopularNames(boysPopular, girlsPopular);

} private static void printPopularNames(ArrayList boysName, ArrayList girlsName) { int i = 0; while(i

if(i=boysName.size()) { System.out.printf("%-60s ", girlsName.get(i)); } if(i>=girlsName.size()) { System.out.printf("%-30s ", boysName.get(i)); } i++; } } }

//My code has some issues.

The desired result is like this:

Write an application called BabyNames1900sAnd2000s to print two columns in alphabetical order.

Aaron Abraham Adam Alex Alexander Andrew Anthony Benjamin Charles Daniel David Edgar Edward Edwin George Henry Isaac Jack Jacob Jake James Jesse John Jose Joseph Juan Kenneth Manuel Mark Martin Matthew Max Michael Nathan Nathaniel Nicholas Oliver Oscar Patrick Paul Peter Raymond Richard Robert Samuel Stephein Thomas Victor Vincent Wesley William Amanda Amelia Amy Anna Audrey Caroline Catherine Charlotte Daisy Elizabeth Ella Emily Emma Eva Evelyn Grace Hannah Isabel Isabelle Julia Katherine Kathryn Katie Laura Lillian Lucy Lydia Madeline Margaret Maria Mary Naomi Rachel Rebecca Ruby Sadie Sara Sarah Sophia Sophie Victoria 2

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!