Question: Task (In java) The task is to write a baby name generator program that takes in the name of a CSV file containing the potential

Task (In java)

The task is to write a baby name generator program that takes in the name of a CSV file containing the potential baby names and the gender as command line arguments. (NOT a Scanner input from the terminal).

Then, you should read in the file of baby names and randomly choose 3 names from the list for that gender and write those out to a new file called "potential_names.txt".

To safeguard against malicious input, you should create a custom exception class called IncompatibleExtensionException that is thrown if the file entered as a command line argument does not end with ".csv". If this happens, tell the user your program only works with CSV files.

Sample Output

java BabyNames yob2020.csv M //will write out 3 randomly selected male names from yob2020.csv to "potential_names.txt"

java BabyNames yob2000.csv F //will write out 3 randomly selected female names from yob2000.csv to "potential_names.txt"

java BabyNames yob1980.txt F //will throw an IncompatibleExtensionException and print to the console that only CSVs are accepted

Test Files

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!