Bag Of Cows

Pseudo Code Library

The Philosophical Restaurant

Challenge 3: All going wrong

The restaurant has been open for a few weeks now, but things are not going so well.

Although the customers don't get the food they hate (unless fate decrees that they should), many of them keep complaining that they don't like the combinations of courses they have been given. This is generating a very negative atmosphere, and often the chef and staff are upset at the behavior of the customers, which they then complain to Edgar about. It is getting very depressing.

As a result, Edgar has decided that all prospective customers will undergo an 'appreciation' test (like an aptitude test, but for customers) and only the least likely to complain will be allowed to eat in the restaurant.

On the day of the customer's booking, they are contacted and given eight random combinations of starter, main and pudding. They have to say if they would be prepared to eat that combination, 'y' or 'n' (not case sensitive). If they answer anything else, they get asked again until they give an acceptable response. The number of 'y' answers is totaled, and the customer's name and their score of 'y' answers is added to a file.

At opening time, Edgar searches through the file and loads the 'appreciation test' scores for each customer. If they have more than one entry, he takes the most recent. He also works out the average score for all customers. He then sorts the list with the highest scores at the top and prints the names of all the customers with an above average score, highest score first. These people are phoned and told that they can come to the restaurant. All the people with below average scores are contacted and told that the restaurant is closed that evening.

Edgar hopes that by doing this, there will be a more appreciative atmosphere in the restaurant.

Requirements: part 1

Write a program which:

  1. Asks the customer their name
  2. Start a running total at zero
  3. Repeats the following 8 times
    1. Randomly choose a starter, main and pudding
    2. Show the customer the meal
    3. Ask them to type 'y' or 'n' to the meal (don't accept anything else)
    4. If the response is 'y', add one to the running total of 'y' responses
  4. Add the customer name and the number of 'y's to a text file


Please base your code on the challenge 3 template here.

Download and complete the challenge 3 evidence document.



Pick a random combination of meals (2) Run the program and show that different meals are selected
Ask a total of 8 questions(2) Show that the customer is asked to rate the meal exactly 8 times
Accept only 'y' and 'n'(2) Enter the following:
y - should be accepted
Y - should be accepted
n - should be accepted
N - should be accepted
No - should be rejected
Yup - should be rejected
Correctly count the responses (2) Answer 'y' to all 8 questions - show that 8 is the score
Answer 'n' to all 8 questions - show that 0 is the score
Answer 'y' to four of the questions - show that 4 is the score
Show the results are added to a file (2) Show the contents of your data file before and after the customer 'Eileen' answers 'y' to 3 out of 8 meals

Requirements: part 2

Write a program which:

  1. Reads in the customer scores from a file
  2. Makes a list of the customers and their most recent score
  3. Calculates the average score
  4. Sorts the customers by score, highest first
  5. prints the names of the customers in order, but only those with an above average score



Get the most recent scores(2) Enter data for the file which includes two entries for Carol - the first time she chose 'y' 5 times, the second time 6 times.
Show that the value used for Carol was 6
Calculate the average(1) Show, by doing the calculation yourself, that the average was correct.
Sort the names(2) Show, by printing all the customer names and their scores that the sorting has been done correctly.
Display only those above average(1) Show, by printing the customer names and their scores only those above average have been selected.