# Pseudocode check

1. Aug 26, 2010

### Travian

1. The problem statement, all variables and given/known data
In 2014 Fifa (the world governing body for international football) would like to revise the way teams are allocated points for the group stage of the World Cup as shown below:

Result Points
Win 3
Draw 1
Lose 0
Win (with penalty shootout) 2
Lose (with penalty shootout) 1

Design an algorithm using pseudocode that analyses the result of a match and awards points to the two teams accordingly.

2. Relevant equations

3. The attempt at a solution

Algorithm
Code (Text):

Declare firstTeamGoals, secondTeamGoals, firstPen, secondPen as integer
Write “Please enter first team amount of goals”
Get firstTeamGoals ;
Write “Please enter second team amount of goals”
Get secondTeamGoals ;
IF (firstTeamGoals > secondTeamGoals) THEN
Write “First team receives 3 points and second team receives 0 points”
ELSEIF (firstTeamGoals < secondTeamGoals) THEN
Write “First team receives 0 points and Second team receives 3 points”
ELSE
IF (firstTeamGoals == secondTeamGoals)
Write “Please input the number of scored penalties (first team)”
Get firstPen ;
Write “Please input the number of scored penalties (second team)”
Get secondPen ;
IF (firstPen > secondPen) THEN
Display “First team receives 2 points and second team receives 1 point”
ELSE
Display “First team receives 1 point and second team receives 2 points”
ENDIF
ENDIF
ENDIF
I just want someone to confirm is this right. If not - where's the problem. Thank you.

2. Aug 26, 2010

### Staff: Mentor

I'm no expert in soccer/futbol, but when you ask for "number of goals" and then ask for "number of penalty points", I don't think that's correct for this problem. It seems like you should ask if the game was won with a tie-breaking shootout first, and if the answer is no, then ask for the final score. I think "penalty kicks" are different from the tie-breaking shootout. Guess I should learn more about soccer

3. Aug 26, 2010

### Travian

Well the number of goals scored determines the winner. Isnt that right?

4. Aug 26, 2010

### Staff: Mentor

I don't know enough about soccer (as we in the US call it) to know if your algorithm is correct, particularly the part about the penalty shootouts (or even what that means).

Having said that, I don't think your algorithm is correct, since it doesn't seem to take draws into consideration.

I would think the algorithm would need to see if there was a penalty shootout first.

if (penalty shootout is true) then award 2 pts to winner and 1 pt to loser
otherwise if there is a winner, then award 3pts to winner and 0 pts to loser
otherwise award 1 pt to each team

5. Aug 26, 2010

### Staff: Mentor

Correct, but I think that includes the tie-breaking shootout goals. Your code above seems to assume that you will be given a tie score if there was a shootout after the tie. I apologize if I'm not interpreting the question or misunderstanding how soccer is scored.

6. Aug 26, 2010

### Travian

Result Points
Win 3
Draw 1
Lose 0
Win (with penalty shootout) 2
Lose (with penalty shootout) 1

This is what the exercise says. You cannot receive 0 points if you loose after penalty shootout.

And yes, i think i missed the part where extra time commences.

7. Aug 26, 2010

### Staff: Mentor

Better information from wikipedia.org:

http://en.wikipedia.org/wiki/Soccer

So I guess the tie-breaker shootout goals are handled differently.