01.Blogs :
RobMiles  
Programming, gadgets and life as a lecturer in a UK university.

Exam Question 1

Most people in my programming exam got the problem with this code. Can you? There'll be another tomorrow

switch (command) {
      case 'a':
      case 'A':
            AddEntry();

      case 'd':
      case 'D':
             DeleteEntry();

      default :
            System.out.println ( "Invalid command" ) ;
}

posted on Monday, May 24, 2004 3:39 PM by RobMiles

# @ Monday, May 24, 2004 3:45 PM

theres no break after the AddEntry and DeleteEntry? Hang on, im voluntarily attempted exam questions, that shouldnt be right. On another note, how do you react to little comments and drawings by students in their exam papers?

lukesmith

# @ Monday, May 24, 2004 7:35 PM

Well done. You are correct. That would have been 5 marks! Little comments and drawings in the papers do help raise a smile, but I'm afraid they have no effect on the marks....

RobMiles

# @ Monday, May 24, 2004 8:25 PM

5 marks?? Come down and lecture at Reading if your papers are that easy please

lukesmith

# @ Monday, May 24, 2004 8:34 PM

Out of 100. Explanation required. And that was just the first part of the question....... More tomorrow..

RobMiles

# @ Tuesday, May 25, 2004 1:43 AM

Of course in C# you woud at least get an error. C++ and Java it would happily do the wrong thing. IN Visual basic .NET though you could say: Select Case command Case "A", "a" AddEntry() Case "D", "d" DeleteEntry() Case Else Console.Out.WriteLine("Invalid command") End Select And all would be fine because it woud work as you expect - stop at the end of the Case clause.

AlfredTwo

# @ Tuesday, May 25, 2004 1:54 AM

Hum, well that code didn't format very well did it. See my blog http://www.thespoke.net/MyBlog/AlfredTwo/MyBlog_Comments.aspx?ID=20764 for a better formatted version and some additional comments.

AlfredTwo


 
03.UPDATE CALENDAR :
<May 2004>
SunMonTueWedThuFriSat
2526272829301
2345678
9101112131415
16171819202122
23242526272829
303112345

05.MY LINKS :

07.Subscriptions :

Subscriptions


© Copyright 2005 Microsoft Corporation. All Rights Reserved.
Terms of Use | Privacy Statement | Code of Conduct | Hosted by MaximumASP for Microsoft
WHO-BAR