Question: Consider a City class that has: private instance variables: private String CityName private String countryName private double[] averageMonthlyRainfall An appropriate constructor The following public methods:

Consider a City class that has:

private instance variables:

private String CityName

private String countryName

private double[] averageMonthlyRainfall

An appropriate constructor

The following public methods:

public String getCityName( )

public String getCountryName( )

public double[ ] getAverageMonthlyRainfall( )

public void addMonthlyAverageRainfall(double rainfall) throws IllegalArgumentException

public void modifyMonthlyRainfall(double rainfall, int monthNum) throws IllegalArgumentException

public String toString( )

public boolean equals(Object obj) - comparison based on cityName and CountryName

Implement a well-structured Java program that uses the City class and CityDriver class to enable a climate scientist to maintain city monthly average rainfalls of up to 12 months. The average rainfall information is kept in a text-file rainfall.txt of the form:

where each line of the text-file contains a city name (a single word), a country name (a single word), followed by up to twelve monthly average rainfall values in millimeters (The above table shows the monthly average rainfall for January, February, and March only)

Note: The initial input file has no rainfall information. It is in the form:

Arusha Tanzania

Athens Greece

Bali Indonesia

DarEsSalaam Tanzania

Dubai UAE

Dublin NorthernIreland

London UK

Manila Philippines

Your CityDriver program must have the following main menu:

1. Display Rainfall Infomation for all cities.

2. Display Rainfall Infomation for a particular city.

3. Display total rainfall for each city.

4. Modify a particular rainfall average for a particular city and country pair.

5. Add monthly rainfall average for the current next month for all cities.

6. Add New city.

7. Delete a city.

8. Exit.

Please select your choice:

Your program must loop as long as option 8 has not been selected. It must display an appropriate error message if an invalid choice is entered. After executing each of the options 1 to 7, your program must pause and display the message: Press Enter key to continue . . . . Your program must display the main menu after pressing the Enter key. Each of the options 1 to 7 must be implemented in a separate private static method. The code for Press Enter key to continue . . . must also be implemented is a separate private static method. Your main method must handle IOException, IllegalArgumentException, and InputMismatchException by displaying an appropriate error message, then waiting for a key press, before returning control to the main menu.

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!