COMP2243 - Programming and Problem Solving

Syllabus Software Installation Assignments Tests
Lectures and Labs
**Back to Full Menu**

Arrays ArrayProcessing.java BookRating.java BookRatingWithFileIO.java Book Rating OOP Program
Book.java
BookRatingClient.java
Array of Objects Program
City.java
CityClient.java




Array Of Objects Program


Description

This program uses an array of City objects to store city information (name and population) and uses several methods to do the following:

Fill in the array with the user input data

Print cities' name and population stored in the array

Search the array to find the the city with the most population (assume there is no tie) and print the result

Associated Concepts:

Array

OOP

Algorithm:

For City class, the class diagram is represented in UML (Unified Modeling Language) notation.



Client program:

Create an array of City class to store 5 cities' data

Call methods to:

Populate the arrays based on the user input data

Print array elements

Find the index of the city with the most population and print the result

Source Code





Sample Run



Video