master
..
rw-r--r--
2.0 KB
rw-r--r--
1.8 KB
rw-r--r--
1.6 KB
rw-r--r--
2.4 KB

Learning Profile for Assignment #2, And Question #5

Name: Mo Khan Student ID: 3431709

  1. Problem Statement:

Create three classes: Village, Citizen, and ComputeIntellect.

The Village class has an instance variable called numberOfCitizens and an array that holds a maximum of 100 Citizen objects.

The Citizen class has citizenId and educationalQualification as instance variables.

The ComputeIntellect class has a distributionOfQualification() method.

Create 100 Citizen objects using citizenId for the range 1 to 100.

Randomly generate the educational qualification in the range 1 to 4, where

1. high school
1. undergraduate
1. postgraduate
1. doctorate

Store these 100 objects in a Village object using an array – any array of your choice. The distributionOfQualification() method loops through the 100 objects and counts the number of citizens corresponding to each of the four educational qualifications.

  1. Description of the Code:

The code has 3 classes. The entry point into the console application is in the Village class. I chose to store the citizens of the village in a generic ArrayList<T>.

  1. Errors and Warnings:

This program does not accept any user input.

  1. Sample Input and Output:

Running the program yields output like the following:

```bash
$ mvn package
$ java -cp target/assignment2*.jar ca.mokhan.comp268.App 5
Welcome to the village
The village has 100 citizens
23 citizens have a doctorate
25 citizens have a post graduate degree
33 citizens have a under graduate degree
19 citizens have a high school diploma
```
  1. Discussion