blob: 4d4fac950decda9299aa36ac7a3b105cd1fb646f (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
|
Learning Profile for Assignment #2, And Question #5
Name: Mo Khan
Student ID: 3431709
1. Problem Statement:
```text
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,
* 2 = undergraduate,
* 3 = postgraduate,
* 4 = 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:
1. Sample Input and Output:
```bash
Choose exercise: (1-10)
5
Welcome to the village
The village has 100 citizens
29 citizens have a doctorate
24 citizens have a post graduate degree
21 citizens have a under graduate degree
26 citizens have a high school diploma
```
1. Discussion:
|