Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

The program first reads integer townCount from input, representing the number of pairs of inputs to be read. Each pair has a string and an

The program first reads integer townCount from input, representing the number of pairs of inputs to be read. Each pair has a string and an integer, representing the town's name and population, respectively. One Town object is created for each pair and added to ArrayList townList. Write the findAverageTownPopulation() method in the SmallCities class to return the average population of all the Town objects as an integer.
Ex: If the input is:
4
Adomstown 1804 Asaph 4700 Davids 3000 Hum 4800
then the output is:
Average town population: 3576
Note: The ArrayList has at least one element. import java.util.Scanner;
import java.util.Arraylist;
public class SmallCities {
private ArrayList=
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Data Mining Concepts And Techniques

Authors: Jiawei Han, Micheline Kamber, Jian Pei

3rd Edition

0123814790, 9780123814791

More Books

Students also viewed these Databases questions

Question

Which of the following is an example of user innovation

Answered: 1 week ago

Question

What are you getting out of this situation?

Answered: 1 week ago

Question

What do you understand by Mendeleev's periodic table

Answered: 1 week ago