0% found this document useful (0 votes)
3 views2 pages

CISP300 HC6 Pseudocode

Uploaded by

Marc Olmsted
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views2 pages

CISP300 HC6 Pseudocode

Uploaded by

Marc Olmsted
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

Start

Module Main()
Declare String cashOut = ""
Declare Integer totalBet = 0
Declare Integer totalWon = 0

Do
Call RunSlots(totalBet, totalWon, cashOut)
Until cashOut == C or cashOut == c

Call DisplayWinnings(totalBet, totalWon)


End Module

Module RunSlots(Integer Ref totalBet, Integer Ref totalWon, String Ref cashOut)
Declare String wordOne = ""
Declare String wordTwo = ""
Declare String wordThree = ""
Declare Integer betAmount = 0
Declare Integer winnings = 0
Declare Integer matchCount = 0

Display "Enter bet amount: "


Input betAmount

Set wordOne = Getword()

Set wordTwo = Getword()

Set wordThree = Getword()

If wordOne == wordTwo and wordTwo == wordThree Then


Set matchCount = 3
Display "Three words matched, four times bet won. "
Else If wordOne == wordTwo or wordOne == wordThree or wordTwo == wordThree Then
Set matchCount = 2
Display "Two words matched, 1.5 times bet won. "
Else If wordOne != wordTwo and wordTwo != wordThree
set matchCount = 0
Display "No Matches.
End If
End If
End If

Set winnings = CalculateWinnings(betAmount, matchCount)


Set totalWon = totalWon + winnings
Display "You have won ", winnings, " Dollars! "
Display 'To cash out, enter C. "
Display "To continue, enter any other letter."
nput cashOut
End Module

Function String GetWord()


Declare Integer number = 0
Declare String word = ""

Set number = Random(1, 6)


If number == 1 Then
Set word = Grapes
Else If number == 2 Then
Set word = Oranges
Else If number == 3 Then
Set word = Berries
Else If number == 4 Then
Set word = Bells
Else If number == 5 Then
Set word = Melons
Else If number == 6 Then
Set word = Bars
End If
End If
End If
End If
End If
End If
Return Word
End Function

Function Integer CalculateWinnings(Integer betAmount, Integer matchCount)


Declare Integer multiplier = 0
Declare Integer amountWon = 0

If matchCount == 3 Then
Set multiplier = 4
Else If matchCount == 2 Then
Set multiplier = 1.5
Else if matchCount == 0 Then
Set multiplier = 0
End If
End If
End If
Set amountWon = betAmount x multiplier
Return amountWon
End Function

Module DisplayWinnings(Integer totalBet, Integer totalWon)


Display "Total amount bet: $", totalBet
Display "Total amount won: $", totalWon
Display "Thank you for playing! "
End Module

End

You might also like