Answered step by step
Verified Expert Solution
Question
1 Approved Answer
FRQ: Air Quality Analyzer. PLEASE COMPLETE MAIN CLASS, THANK YOU! Your code should use ArrayLists instead of Arrays. Provided in your starter code is a
FRQ: Air Quality Analyzer. PLEASE COMPLETE MAIN CLASS, THANK YOU!
Your code should use ArrayLists instead of Arrays.
Provided in your starter code is a City.java class with the name of the city and the pmValue for the city as private instance variables. The class also provides constructors (default and parameter) and get() methods for the instance variables and a loadValues() and a toString() method.
In the starter code you will see multiple places where you will need to write additional code. Make sure you write the implementation code for:
- In the City.java class, you will need to change the city names and the pmValues from the sample values provided. Use the data set (A) provided to you by your teacher for your values.
- main() method should have the following:
- create one ArrayList of City objects and initialize the ArrayList with City objects using the loadValues() method of the City.java class
- call printData() passing the City ArrayList as argument
- call findMax() passing the City ArrayList and printing all cities with the worst air quality
- call findMin() passing the City ArrayList and printing all cities with the best air quality
- Your main() method may need some local variables and loops to accomplish the above tasks
- printData() This method has a parameter for the City ArrayList and should print the name of the city and the pmValue (the toString() method of the City class already does this)
- findMax() This method has a parameter for the City ArrayList and should find and return the maximum value of all the pollution values.
- findMin() This method has a parameter for the City ArrayList and should find and return the minimum value of all the pollution values.
Step 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