143k views
2 votes
Write a program to simulate a Fruit Machine that displays three symbols at random from Cherry, Bell, Lemon, Orange, Star, Skull.

The player starts with £1 credit, with each go costing 20p. If the Fruit Machine “rolls” two of the same symbol, the user wins 50p. The player wins £1 for three of the same and £5 for 3 Bells. The player loses £1 if two skulls are rolled and all of his/her money if three skulls are rolled. The player can choose to quit with the winnings after each roll or keep playing until there is no money left.

1. Write pseudo or flowchart for this task ready for it to be coded in class tomorrow - 1/12/2020
2. needs - variable, iteration - while because of some condition, selection - it's all the IFs, Sequence - be careful of sequence


please this is urgent i beg u

User Grunt
by
4.7k points

1 Answer

6 votes

Final answer:

To simulate a Fruit Machine, you can use a combination of variables, iteration, selection, and sequence in your program. The program starts with 1 credit and keeps subtracting 0.2 credits with each play. It generates three random symbols and checks for winning combinations. If two symbols match, the credit is increased by 0.5. If three symbols match, the credit is increased by 1, except if the symbol is 'Bell', in which case the credit is increased by 5. If two or three 'Skull' symbols are rolled, the credit is set to 0 and the game ends.

Step-by-step explanation:

To simulate a Fruit Machine, you can use a combination of variables, iteration, selection, and sequence in your program. Here is a pseudo code example:

START

SET credit = 1
WHILE credit >= 0
IF credit < 0.2
EXIT
END IF
SET credit = credit - 0.2
SET symbol1 = randomSymbol()
SET symbol2 = randomSymbol()
SET symbol3 = randomSymbol()
DISPLAY symbols
IF symbol1 = symbol2 AND symbol2 = symbol3
IF symbol1 = 'Bell'
SET credit = credit + 5
ELSE IF symbol1 = 'Skull'
SET credit = 0
ELSE
SET credit = credit + 1
END IF
ELSE IF symbol1 = symbol2 OR symbol2 = symbol3 OR symbol1 = symbol3
SET credit = credit + 0.5
END IF
END WHILE
END

This pseudo code represents the flow of the Fruit Machine simulation. The program starts with 1 credit and keeps subtracting 0.2 credits with each play. It generates three random symbols and checks for winning combinations. If two symbols match, the credit is increased by 0.5. If three symbols match, the credit is increased by 1, except if the symbol is 'Bell', in which case the credit is increased by 5. If two or three 'Skull' symbols are rolled, the credit is set to 0 and the game ends.

User Jassica
by
5.3k points