Question: This project requires the use of an Integrated Development Environment ( IDE ) to develop your code. An editor will not be provided in this
This project requires the use of an Integrated Development Environment IDE to develop your code. An editor will not be provided in this assignment, please see the previous sections for instructions on how to setup and use an IDE.
Problem Description and Given Info
A local climate researcher would like some help with their climate data analysis. They would like a program to help them identify the hottest and coldest cities in various climate zones. They have temperature data for the major U S cities within each climate zone, stored in text files that contain the name of the city, the name of the state, the high temperature, and the low temperature for each city in the climate zone. Each data field is separated by a space. For example, one line in a climate zone data file would look like:
Denver Colorado
The researcher would like the program to do the following:
Present a menu with the following options:
Open a climate zone data file
List all cities
List hottest cities
List coldest cities
Add a city
Change a city's temperatures
Count cities
Quit program
When the user chooses to open a climate zone data file, the program will ask for the file name of a climate zone data file, then open and read the data from that file into an ArrayList.
When the user chooses to list all cities, the program will list the name, state, high temp. and low temp. of all cities in the current climate zone.
When the user chooses to list the hottest cities, the program will determine and list the name, state, high temp. and low temp. of the cities with the highest high temperatures in the current climate zone.
When the user chooses to list coldest cities, the program will determine and list the name, state, high temp. and low temp. of the cities with the lowest low temperatures in the current climate zone.
When the user chooses to add a city, the program will prompt the user to enter the new city's name, state name, high temp. double and low temp. double The program should collect this information from the user, and then instantiate a new City object with the given name and info, and add that city to the current ClimateZone.
When the user chooses to change a city's stats, the program will prompt the user to enter the city's name and the state name. If there is a City in the current climate zone with the given name and state, then the program will collect the new high temp. double and low temp. double and will update the temperature values for this city.
When the user chooses to count the cities in the current climate zone, the program will display the number of cities in the current climate zone.
When the user chooses the program will end.
The Main class has already been designed and written for this program. Carefully review the code in the Main.java file and be sure that you understand how it works.
Your task is to implement the City and ClimateZone classes. The City class will allow us to instantiate City objects that will store the important information name state, high temp., low temp. for a city. The ClimateZone class will allow us to create and manage a list of cities we will use an ArrayList to store the City objects.
Part Implement the City Class
In a file named City.java, implement the class described below.
The City class must have the following private instance variables:
a variable named name that will store a String
a variable named state that will store a String
a variable named highTemp that will store a double
a variable named lowTemp that will store a double
The City class must have the following public constructor method:
an overloaded constructor that takes four arguments. The first argument will be a String city name The second argument will be a String state name The third high temp. and fourth low temp. arguments will be type double.
The City class must have the following public methods:
a method named getName. This accessor method will take no arguments. This method will return a String.
a method named getState. This accessor method will take no arguments. This method will return a String.
a method named getHighTemp. This accessor method will take no arguments. This method will return a double.
a method named setHighTemp. This mutator method will take one double argument. This method will not return anything.
a method named getLowTemp. This accessor method will take no arguments. This method will return a double.
a method named setLowTemp. This mutator method will take one double argument. This method will not return anything.
a method named printInfo. This method will take no arguments. This method will not return anything.
Other Details
The overloaded constructor should initialize the object's name, state, highTemp and lowTemp variables with the values passed in to the parameter variables.
The getName accessor method should simply simply return the value stored in the object's state variable.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
