Bag Of Cows

Pseudo Code Library

The Philosophical Restaurant

Challenge 2: Things get better and better

Edgar has recently come across the theory of Nominative Determinism. This says that a person's actions in life (e.g. their job) is to some extent determined by their name. For example, there are dentists called Mr Payne, Belgian footballer Mark De Man, the Vicar Mr Sermon... And so on.

A new system will now be devised, where instead of choosing a number, the first three letters of the customer's name will be used as the 'offset' for their starter, main and pudding. So A=1, B=2 C=3 etc. While it is now possible that they may get the meal they hate most (if their letter happened to give them a number which was the same as the number of choices), that is just fate really.

Requirements

Take a copy of your program for challenge 1 and adapt it so that:

  1. The program should ask for the customer's name
  2. Do not ask for their number, instead:
    1. Store the position in the alphabet of the first letter of the name as 'starter_offset'
    2. Store the position in the alphabet of the second letter of the name as 'main_offset'
    3. Store the position in the alphabet of the third letter of the name as 'pudding_offset'
       BR> Hint: If you know the ASCII value of the letter, and knowing that 'A' has ASCII value 65, you can easily work out the position in the alphabet of any letter - especially if you make sure to convert everything to upper case.
  3. Change your code which selects the starters, mains and puddings so that it uses these new variables
  4. Tell the customer what offset values are being used

Resources

Download and complete the challenge 2 evidence document.

Marks

Tests

Calculate the offsets (6) Show that customer 'Abbi McAbbeville' has offsets of 1,2 and 2
Show that customer 'Ben Benson' has offsets of 2,5 and 14
Use the offsets (4) Show that customer 'Abbi McAbbeville' choosing starters, mains and puddings gets the correct food
Show that customer 'Ben Benson' choosing starters, mains and puddings gets the correct food