Assessment 2011 2 Medium

From Progzoo
Jump to: navigation, search

Which days are busiest?

Show the number of events for each day of the week. You might want to use a structure such as this:

HashMap<String,Integer> dow =
   new  HashMap<String,Integer>();
dow.put("Monday",0);
dow.put("Tuesday",0);
dow.put("Wednesday",0);
dow.put("Thursday",0);
dow.put("Friday",0);

For each event add one to the corresponding day.

You can then loop over dow.keySet() - don't worry about the order.


[Font] [Default] [Show] [Resize] [History] [Profile]



Free days for Co.Cc1f-B

For the student group Co.Cc1f-B print the days of the week with no teaching events. The days of the week might be represented using a HashMap such as:

HashMap<String,Integer> dow = new  HashMap<String,Integer>();
dow.put("Monday",0);
dow.put("Tuesday",0);
dow.put("Wednesday",0);
dow.put("Thursday",0);
dow.put("Friday",0);

You can then loop over all events; for each event loop over all students. If the student group matches Co.Cc1f-B then put 1 in the dow hashmap - that will overwrite the 0.

After that loop the dow structure will contain a 1 if the students have something on that day; otherwise the value will still be 0. You can loop over the keySet for dow and print it only if it contains 0.


[Font] [Default] [Show] [Resize] [History] [Profile]

When is A17 Free?

List the timeslots (from Monday 9:00 to Friday 17:00) when Merch.A17 is free. You may want to use a HashMap containing all time slots:

HashMap<String,Boolean> slots = new HashMap<String,Boolean>();
for (String day:dow.keySet())
  for (int i=9;i<=17;i++)
    slots.put(day+i+":00",false);

You can then run through all the events and change the corresponding entry to false if the event is in A17. You will need to worry about events that are longer than one hour.


[Font] [Default] [Show] [Resize] [History] [Profile]

Friend of a friend

Two groups are "friends" if they share any teaching event. List the friends of friends of Co.Cc1f-B


[Font] [Default] [Show] [Resize] [History] [Profile]

How many hours for Computing Suite Students

For each of the student groups that start with the code Co.Cc1f print the student group and the total number of contact hours per week,


[Font] [Default] [Show] [Resize] [History] [Profile]