Best writers. Best papers. Let professionals take care of your academic papers

Order a similar paper and get 15% discount on your first order with us
Use the following coupon "FIRST15"
ORDER NOW

AVAIMPORTANT:  This program MUST be one .java file with ONE class called Titanic

AVA<br/>IMPORTANT:  This program MUST be one .java file with ONE

class called Titanic.  NO COMMAND LINE.  The titanic.txt file must be read into the program.  I MUST HAVE A FEW SCREENSHOTS OF THE PROGRAM WORKING IN THE IDE.
I ATTACHED A PROGRAM THAT I BELIEVE IS GOOD, BUT MY TEACHER JUST INFORMED ME THAT WE ARE NOT TO USE ANY COMMAND LINE.  SO IF SOMEONE CAN CHANGE THAT AND GET IT TO WORK…GREAT!
Project:
Design, implement and test a Java application that will read a file containing data related to the passengers on the Titanic. The description of the file is shown below. The application should provide statistical results on the passengers including:
a. Total number of passengers on the Titanic
b. Percentage of passengers who perished on the Titanic
c. Percentage of Passengers who survived the sinking of the Titanic
d. Percentage passengers who survived the sinking of the Titanic as a function of the passenger class (e.g. 1,2,3)
e. A list of the names of passengers who were less than 10 years old who perished on the Titanic
f. The count of the number of passengers as a function of the first letter of their last name. (e.g., A: 13, B:33 …)
g. At least one additional statistical results you add to enhance the functionality

The following are some design criteria and specific requirements that need to be addressed:
a. Only one class called Titanic .
b. Use a 2D array to store the Titanic data. (Hint: You will probably need to store the array as String values and then convert to other types as needed since some data is null)
c. You should create separate methods for each of the required functionality. (e.g. getTotalPassengers() will return the total number of passengers on the Titanic.)
d. A user-friendly and well-organized menu should be used for users to select which data to return. A sample menu is shown in run example. You are free to enhance your design and you should add additional menu items and functionality.
e. The menu system should be displayed within the IDE, and continue to redisplay after results are returned or until Q is selected. If a user enters an invalid menu item, the system should redisplay the menu with a prompt asking them to enter a valid menu selection
f. The application should keep track of the elapsed time (in seconds) between once the application starts and when the user quits the program. After the program is exited, the application should provide a prompt thanking the user for trying the Titanic program and providing the total time elapsed.

Here is sample run:

********** Welcome to the Titanic Statistical Application **************************
Enter the number of the question you want answered. Enter ‘Q’ to quit the program :
1. How many passengers were on the Titanic?
2. What percentage of passengers perished on the Titanic?
3. What percentage passengers survived the sinking of the Titanic?
4. What percentage of passengers survived for each of the three classes?
5. What specific passengers who were less than 10 years old survived the sinking of the titanic?
6. For each letter in the alphabet, how many passengers last names started with that letter?
Q. Quit the program

Enter your selection: 1

There were 1310 Passengers on the Titanic.

Enter the number of the question you want answered. Enter ‘Q’ to quit the program :
1. How many passengers were on the Titanic?
2. What percentage of passengers perished on the Titanic?
3. What percentage passengers survived the sinking of the Titanic?
4. What percentage of passengers survived for each of the three classes?
5. What specific passengers who were less than 10 years old survived the sinking of the titanic?
6. For each letter in the alphabet, how many passengers last names started with that letter?
Q. Quit the program

Enter your selection: Q
Thank you for trying the Titanic Program.
Elapsed time in seconds was: 95

Titanic Data Description:
The attached tab delimited file, named titanic.txt contains the known passengers on the Titanic. There are 6 fields included in the file in the order:
Passenger class (1,2,3)
Survived (1=yes, 0=no)
Name (Passenger name)
sex (male or female)
age (some values are blank)
fare (some values are blank)

import java.io.File;import java.io.FileNotFoundException;import java.util.Scanner;/**** @author*/public class MyName {//name of filepublic class Titanic {// java class Titanic//declare and initialize variablesint MAXPASSENGERS = 10000;int actualPassengers = 0;//B. Use a 2D array to store the Titanic data.String[][] data = new String[MAXPASSENGERS][6];/*** Constructor to read file and set 2D array to store the Titanic data*/Titanic(String filename) throws FileNotFoundException {Scanner fileReader = new Scanner(new File(filename));while (fileReader.hasNextLine()) {//line has tab delimeted datadata[actualPassengers++] = fileReader.nextLine().split(“\t”);}//end whilefileReader.close();}/**** @return Total number of passengers on the Titanic*/public int getTotalPassengers() {return actualPassengers;}//end getTotalPassengers/**** @return Total number of passengers who perished on the Titanic*/public int getTotalNumberofPerishedPassengers() {int count = 0;for (int i = 0; i < getTotalPassengers(); i++) {int status = Integer.parseInt(data[i][1]);//Survived (1=yes, 0=no)if (status == 0) {count++;}//end if}//end forreturn count;}//end getTotalNumberofPerishedPassengers/**** @return Total number of Passengers who survived the sinking of the* Titanic*/public int getTotalNumberofSurvivedPassengers() {return getTotalPassengers() – getTotalNumberofPerishedPassengers();}//end getTotalNumberofSurvivedPassengers/**
Background image of page 1
* Number of passengers who survived the sinking of the Titanic as a* function of the passenger class (e.g. 1,2,3)** @param cls* @return*/public int getTotalNumberofSurvivedPassengersByClass(int cls) {int count = 0;for (int i = 0; i < getTotalPassengers(); i++) {int status = Integer.parseInt(data[i][1]);int clazz = Integer.parseInt(data[i][0]);//Survived (1=yes, 0=no)if (status == 1 && clazz == cls) {count++;}//end if}//end forreturn count;}//end getTotalNumberofSurvivedPassengersByClass/*** Number of passengers who survived the sinking of the Titanic as a* function of the passenger gender (e.g., male, female)** @param cls* @return*/public int getTotalNumberofSurvivedPassengersByGender(String gender) {int count = 0;for (int i = 0; i < getTotalPassengers(); i++) {int status = Integer.parseInt(data[i][1]);//Survived (1=yes, 0=no)if (status == 1 && gender.equalsIgnoreCase(data[i][3])) {count++;}//end if}//end forreturn count;}//end getTotalNumberofSurvivedPassengersByGender/**** @param cls* @return A list of the names of passengers who paid greater than given* fair for their tickets*/public String getNamesPaidFare(double fair) {String name = “”;for (int i = 0; i < getTotalPassengers(); i++) {if (data[i].length >= 6) {double pfair = Double.parseDouble(data[i][5]);if (pfair > fair) {name += “\n” + data[i][2];}//end if}//end if}//end forreturn name;}//end getNamesPaidFare/*** G. A list of the names of passengers who were less than 10 years oldwho* survived the sinking of the Titanic** @param fair* @return
Background image of page 2
 
Looking for a Similar Assignment? Order now and Get 10% Discount! Use Coupon Code "Newclient"