Answered step by step
Verified Expert Solution
Question
1 Approved Answer
in java plz General Structure of Your Program Your class containing the main method should be called Your_Initials_Maritime_Analysis.java. Here is where you can do a
in java plz
General Structure of Your Program Your class containing the main method should be called Your_Initials_Maritime_Analysis.java. Here is where you can do a quick explanation of what the program will do and get input from the user as to how the user wants to analyze the data. We want you to reduce the amount of code that appears in your main method. A lot of your operational code will be done inside methods that will be stored in a helper class called Your_Initials_ProjectMethods.java. These methods will be called from the main method. Step 1: First, you need to write a method called buildPassengerArray(). This method will accept as an argument a File class object that contains the name and path to the "Passengers.csv" file. The method will create and return a two dimensional array of type String that contains all of the data from the file. The file contains many rows of data. Each row is ended by an EOL (end of line) character, and each data value in the row is delimited (separated) by a comma separator. The very first row of the file contains the column headings for the table: Surname, First Name, survived, sex, age, and Ticket Class, so you can see by visual inspection that your 2D array will need to have six columns. However, you can get this number of columns information from the file data itself if you read in the first row as a String value, and then use the String class method called split() to break it up into individual tokens based on the comma delimiter. Research this method in the JDK docs. Look at what it returns. Then use this information to determine how many columns will be in your 2D array. So, your method should read this first row in the file, split up the row based on the comma delimiters, and then you can record the column names in an array of type String. Then your method will need to loop through the file and just count how many rows there are in the file so that you can properly size the 2D array. Once you have determined the number of rows in the file, you can instantiate the two dimensional array that you can call tableArray. Then your method needs to POPULATE the empty 2D tableArray by reading the file again. The column headings you recorded in the String array should go into the very first row of the 2D array. Then the rest of the data needs to go into the remaining rows of the tableArray. You method should then close all Scanner objects that you created to build this tableArray. Step 1: First, you need to write a method called buildPassengerArray(). This method will accept as an argument a File class object that contains the name and path to the "Passengers.csv" file. The method will create and return a two dimensional array of type String that contains all of the data from the file. The file contains many rows of data. Each row is ended by an EOL (end of line) character, and each data value in the row is delimited (separated) by a comma separator. The very first row of the file contains the column headings for the table: Surname, First Name, survived, sex, age, and Ticket Class, so you can see by visual inspection that your 2D array will need to have six columns. However, you can get this number of columns information from the file data itself if you read in the first row as a String value, and then use the String class method called split() to break it up into individual tokens based on the comma delimiter. Research this method in the JDK docs. Look at what it returns. Then use this information to determine how many columns will be in your 2D array. So, your method should read this first row in the file, split up the row based on the comma delimiters, and then you can record the column names in an array of type String. Then your method will need to loop through the file and just count how many rows there are in the file so that you can properly size the 2D array. Once you have determined the number of rows in the file, you can instantiate the two dimensional array that you can call tableArray. Then your method needs to POPULATE the empty 2D tableArray by reading the file again. The column headings you recorded in the String array should go into the very first row of the 2D array. Then the rest of the data needs to go into the remaining rows of the tableArray. You method should then close all Scanner objects that you created to build this tableArray. Step 2: After you have the 2D tableArray built, you present the user with a list of options to do further analysis on the data. The user will be presented with a list of options for analyzing the data. The first option (#1) will be to see a complete list of all the passengers on the list. In order to see the complete contents of the passenger list in your Eclipse console window, you will have to do an adjustment to the Eclipse setting which limits how much data can be displayed in the console window, because it is pre-set to 80,000 characters. There are more than 80,000 characters in this data file, so to learn how to remove this console buffer restriction so that you can view the entire passenger list, check Des Maritime Disaster Analysis Application-- Welcome to 's Maritime Disaster Analysis Application. We are analyzing the maritime disaster involving the ship RMS Titanic. The name of the file holding the data is "Titanic Passengers.csv". Now opening the file and creating the data table... OK, the data has been loaded into the table for analysis. Here is a list of options for analyzing the data. Enter the number of the selection, or enter to exit: To see a complete listing of all passengers, press 1: To get a count of passengers by class AND gender, press 2: To get a count of survivors by class AND gender press 3: To get a count of victims by class AND gender press 4: To get a percentage survival rate by class and gender press 5: To exit the program, enter a 0 (zero): Enter your choice as an integer value and press ENTER: NOTE: You must do some DATA VALIDATION on the user input for the options so that if the user enters any incorrect character type for any of the user inputs the program will not crash, but will just inform the user that they need to re-enter their input. For the option #1 you will need to write a method called printArrayContents() to show the complete passenger list. This will be a void method that just takes the 2D tableArray as its argument and then prints the contents of the table to the console window in a nicely formatted way. You will probably want to experiment with printf() to get a nicely formatted output similar to that shown on the next page. The passenger list for the RMS Titanic: no Surname Abbing Abbott Abbott Abbott Abelseth Abelseth Abelson Abelson Abrahamsson Abrahim Adahl Adams Ahlin Aks Aks Albimona Aldworth Alexander Alhomaki Ali Ali Allen Allen Allison Allison Allison Allison Allum First Name Survived Mr. Anthony no Master. Eugene Joseph no Mr. Rossmore Edward Mrs. Stanton (Rosa Hunt yes Miss. Karen Marie yes Mr. Olaus Jorgensen yes Mr. Samuel no Mrs. Samuel (Hannah Wi yes Mr. Abraham August yes Mrs. Joseph (Sophie Ha yes Mr. Mauritz Nils Martin no Mr. John no Mrs. Johan (Johanna Pers no Master. Philip Frank yes Mrs. Sam (Leah Rosen) yes Mr. Nassef Cassem yes Mr. Charles Augustus no Mr. William Mr. Ilmari Rudolf Mr. Ahmed Mr. William Miss. Elisabeth Walton yes Mr. William Henry no Master. Hudson Trevor yes Miss. Helen Loraine Mr. Hudson Joshua Crei Mrs. Hudson J C (Bessi no Mr. Owen George no Sex male male male female female male male female male female male male female male female male male male male male male female male male female male female male Age 42 13 16 35 16 25 30 28 20 18 30 26 40 0.833299994 18 26 30 26 20 24 25 29 35 0.916700006 2 30 25 18 Class 3rd 3rd 3rd 3rd 3rd 3rd 2nd 2nd 3rd 3rd 3rd 3rd 3rd 3rd 3rd 3rd 2nd 3rd 3rd 3rd 3rd 1st 3rd 1st 1st 1st 1st 3rd no no no no no no ...and lots more lines after this. In the age column if you see a decimal fraction, it indicates the passenger was an infant less than 1 year old. Also, under the First Name column, the names of some passengers are truncated, such as "Mrs. Samuel Abelson (Hannah Wi. This is just the way the data was recorded in the file, so don't worry about it if the first name is truncated. User Options, continued: For option #2, you have to write a method to get a count of passengers based on their ticket class and their gender. The method should be called getPassengerCountByTicketClassAndGender(). This method will take in as an argument the 2D tableArray, a String argument representing the ticket class as it is stored in the table, and a String argument representing the gender of the passenger as it is stored in the table. Below is a screen shot of what you can expect to see: To see a complete listing of all passengers, press 1: To get a count of passengers by class AND gender, press 2: To get a count of survivors by class AND gender press 3: To get a count of victims by class AND gender press 4: To get a percentage survival rate by class and gender press 5: To exit the program, enter a 0 (zero): Enter your choice as an integer value and press ENTER: 2 Enter the passenger class for which you want a count. Enter 1, 2, or 3: 1 Enter the gender for the search: 'F' for female, 'M' for male: F ***The number of female passengers in 1st class was 144. For option # 3, you need to write a method that will return the number of survivors by class and gender. You can call this method getSurvivorCountByTicketClassAndGender(). This method will take three arguments: the 2D tableArray, a String argument representing the ticket class as it is stored in the table, and a String argument representing the gender of the passenger as it is stored in the table. The method will only return those passengers of the specified class and gender who were survivors. Below is a screen shot of what you can expect to see: Enter your choice as an integer value and press ENTER: 3 Enter the passenger class for which you want a SURVIVOR count. Enter 1, 2, or 3: 1 Enter the gender for the search: 'F' for female, 'M' for male: f ***The count of survivors for 1st class female passengers is 139 For option # 4, you need to write a method that will return the number of victims by class and gender. You can call this method getVictimCountByTicketClassAndGender(). This method will take three arguments: the 2D tableArray, a String argument representing the ticket class as it is stored in the table, and a String argument representing the gender of the passenger as it is stored in the table. The method will only return those passengers of the specified class and gender who were victims. Enter your choice as an integer value and press ENTER: 4 Enter the passenger class for which you want a VICTIM count. Enter 1, 2, or 3: 1 Enter the gender for the search: 'F' for female, 'M' for male: F ***The count of victims for 1st class female passengers is 5 5 For option # 5, you need to write a method that will return the survival percentage of passengers by gender and class. You can call this method getPercentageSurvival RateByGenderAndClass(). The method will take as arguments the tableArray and arguments for gender and class and then calculate and return the percentage survival of those passengers ROUNDED to two decimal places. Below is a screen shot of what you can expect to see: Enter your choice as an integer value and press ENTER: 5 Enter the passenger class for which you want a count. Enter 1, 2, or 3: 1 Enter the gender for the search: 'F' for female, 'M' for male: F For female passengers in 1st class the percentage survival rate was 96.53%. BONUS OPTION NOTE: YOU CAN SCORE THE BONUS MARKS ONLY IF ALL OF THE BASIC REQUIREMENTS OF THE PROJECT ARE MET AND ARE COMPLETELY FUNCTIONAL. YOU CANNOT USE THE BONUS REQUIREMENT TO MAKE UP FOR MARKS LOST FOR MISSING THE BASIC FUNCTIONALITY. FULFILL THE BASIC REQUIREMENTS COMPLETELY BEFORE EVEN THINKING ABOUT DOING THE BONUS. If you are up to the challenge, there are an additional three bonus marks available. You have to write a method that will allow the user to get a count of survivors OR victims in a particular age range. Call this method getSurvivororVicitimCountByAgeRange(). The user will specify whether they want to see the survivor count or the victim count, and the lower and upper limits of the age range. If you want to try for these bonus marks, add this to your user options list as 2 STYLE: Appropriate pseudo-code statements are done and program is well documented with comments. Documentation header is complete. Program compiles without errors and runs without crashing. Naming conventions followed, variable, constant, and method names are all representative of what each does. No compiler warnings for unused variables or unclosed objects. Basic Requirements Overall layout and functionality of the program is good.. Data validation is done on user input as specified. 2 3 METHOD buildPassengerArrayo: -FILE HANDLING: Successfully opens and reads the data in the input file to correctly size the 2D array. -method returns the filled 2D array to the main. -incorporates exception handling. -properly closes any Scanner objects used to read from the files. 1 Method printArrayContents(): Method is fully documented, and is a void method that just prints out a formatted presentation of the file contents 3 METHOD: getPassengerCountByGenderAndClass(). Method is fully documented and returns total number of male or female passengers in the specified ticket class. 3 METHOD:getSurvivorCountByTicketClassAndGender() Method is fully documented returns total number of male or female survivors in the specified ticket class. METHOD:getVictim CountByTicketClassAndGender() Method is fully documented returns total number of male or female survivors in the specified ticket class. 3 3 METHOD: getPercentageSurvivalRateByGenderAndClass() Method is fully documented returns the percentage survival rate for the specified gender and class as a double rounded to two places. TOTAL 20 3 BONUS: method that allows the user to get a count of survivors or victims in a particular age range. NOTC all mathade ahova muet ha dona and namnlatak functionalStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started