In this practice-exam you are going to build “The Britania Passenger app!”. This application registers the passengers for the ship ‘The Britania’. For each passenger the name, sex, age, weight and travel-class are registered.
When the user starts the application, a menu will be shown. This menu offers the following options and functionality.
Note: the number of passengers will initially be zero (0). After choosing menu option 1, passengers read from the csv file should be present in the system and the number of passengers should be updated accordingly.
Option 1: Read from passengers.csv
The application will read the file passengers.csv and add all passengers mentioned in that file. Make sure that the first line from the csv file will be skipped.
Option 2: Show an overview of the passengers
The application gives an overview of all the passengers. For each passenger show the following data:
Option 3: Add a passenger
The application prompts the user for a name, sex, class, age and weight. The application checks if the entered information lies between the mentioned boundaries. If this is not the case, the user should be prompted again to enter the information.
Item | Rules |
---|---|
Name | May not be empty |
Sex | M, F, N (Male, Female, Non-binary) |
Class | 1,2,3 |
Age | Number between 0 and 110 |
Weight | Number between 40.0 and 120.0 |
Option 4: Show statistics
Present the user with statistics based on the passenger list. The statistics should look as follows.
On top of the screen, the oldest passenger will be shown (in case of multiple passengers with the same age, just pick one of them).
After that the sum of the weights of all the passengers will be shown. Present this value in 1 decimal format.
Below that a visual presentation will be made of the percentage of users traveling in 1st, 2nd and 3rd class. Suppose there are only passengers traveling 1st class, this bar will be fully filled and they others will not be filled. The percentages of the 3 categories should add up to 100%.
Please look at the image below, it will help you with creating the layout.
A few tips to start
new CsvReader(“passengers.csv”);
. You do not need an additional path in this call.