So recently I was asked to help with a university students homework in C# and to my absolute disbelief I could not do it without completely going blank. I was staring at the screen and my brain went into total meltdown. I’m not sure if it was because his Visual Studio was in dark mode (Which by the way is just plain ugly) or because the screen was tiny or whatever or if I’m just looking for excuses but I digress. He didn’t even have code completion/snippets for crying out loud. I’ve put it up on my github now with the answers.
Question 1 was so simple. It was just a case of returning the boolean result yet I didn’t see it.
Question 2 also so simple. It was more a case I just didn’t get what was being asked. Just return the reverse. D’oh!
Question 3 was the breeze.
Question 4 – Unless you’ve got experience of using the modulus operator frequently – it took some thinking.
Question 5 – Same again, apparently this is the traditional gotcha at unis nowadays – FizzBuzz
Needless to say the student thinks I’m thick and won’t be asking for my help in the near future but such is life. Again answers are on my GitHub.
Question 1) Rewrite this method so it isn’t using an if/else statement
var astring = “Test”;
Question 2) Rewrite the method so it returns the reverse of what it is currently.
return (a >= b || c <= d);
Question 3) Remove the redundant code – the only one I got right without thinking!
if(i > 0 && i > 5)
Question 4) Return the start year of the decade so 1996 would be 1990 and end would be 1999
Question 5) For multiples of 3 – print “Fizz”, for multiples of 5 – print “Buzz”, for multiples of 3 and 5 – print “FizzBuzz”.