Professor Evelyn Evil, criminal mastermind and head of the nefarious worldwide organization, the Empire of
Villainy, Illegality and Liquidation (E.V.I.L.) has hatched a dastardly plan for world domination. Only I.A.D.G.T.,
the International Agency for Doing Good Things, stands in her way.
As an agent of IADGT, you have just received information about Prof. Evil's plans and with only the aid of two
safety pins, a small canoe, and your knowledge of Javascript, you have to stop her before it is too late.
Unfortunately, you have just lost the safety pins. And the canoe has sunk. The continuing survival of the
world as we know it, depends on your Javascript skills. Heaven help us all!
You have discovered documents which detail the work of Prof. Evil's top agents throughout the world
together with the number of crimes committed on each continent. Note that, for some reason, probably due
to a morbid fear or kangaroos, E.V.I.L. does not operate in Australia.
Continent
Africa Asia America Europe
Agent
- Ignatia Niminee 17 23 8 15
- Desiree Picable 4 32 5 64
- Malcolm Evolence 31 14 26 27
- Victoria D'Ness 33 11 35 8
- Enos Kryme 22 43 13 22
- 'Che' Di Caracta 31 34 19 35
In order to process the information, you should write a series of short JavaScript programs which perform
the following tasks:
a) Create an array of agents' names, an array of continents and a 2D-array containing the number of evil
activities.
b) Write some code, based on the previous arrays, that will output the following table:
Ignatius Niminee 17 23 8 15
Desiree Picable 4 32 5 64
Malcolm Evolence 31 14 26 27
Victoria D'Ness 33 8 35 28
Enos Kryme 22 43 13 22
'Che' Di Caracta 31 34 19 35
[Note that it is not necessary to get exact alignment of columns.]
(Q2(a)-(b): 1 subgrade)
c) Write a function that will return an array of the number of crimes committed in each continent by a
specified agent. Test the function.
d) Write a function that will return the total number of crimes committed by a specified agent. Test the
function.
e) Write a function that will return the total number of crimes committed on a specified continent. Test the
function.
(Q2(c)-(e): 1 subgrade)
f) Write a function that will return the number of crimes committed on a specified continent by a specific
agent. Test the function.
g) Write a function that will return an array of the average number of crimes committed by agents on a
specified continent. Test the function.
h) IADGT strongly suspects that agents live on the continent on which they are least active. Write a function
that takes in the name of an agent and returns their most likely location. Test the function.
(Q2(f)-(h): 1 subgrade)
i) It is known that Ignatia, Malcolm and Che are assassins whereas the other EVIL agents are bank robbers.
Find the name of the agent who has carried out the most assassinations and agent who has carried out
the most bank robberies.
j) Secret information states that there is a IADGT double-agent within the EVIL organisation. Unfortunately,
EVIL now also suspect this fact and so an urgent extraction needs to take place. You know that the
double-agent is the bank robber with the lowest total activity in Africa and America. Find the identity of
this person so that the extraction can take place.
(Q2(i)-(j): 1 subgrade)
k) Intelligence suggests that Malcolm Evolence and Victoria D'Ness are locked in a bitter struggle to succeed
Prof. Evil as head of the organisation. Success in this depends the votes of the Continental Commanders
and the vote of each commander is given to Malcom or Victoria if they committed the greater number of
crimes on that continent. IADGT can only apprehend one of these criminals and need to know which
agent will succeed. Write a function that will determine which one of Malcolm or Victoria will be Prof.
Evil's successor.
Sample Solution