Write a program that asks the user to guess the next roll of a six sided die. Each guess costs $ 1. If they guess correctly, they get $ 10.00. The player will start out with a $10.00 bank. Each time he (or she) guesses incorrectly you will subtract $1.00 from their bank. Each time they guess correct, you add $10.00 to their bank. Print the total winnings or loss at the end of the game. You can simulate the toss of the dice using the RandomRange function (Don’t forget to Randomize).
Your program should look something like this:
Welcome to the dice guess game. it costs $1.00 to play.Would you like to continue? (y/n)yPlease enter your guess for the next roll. It only costs $1.00 to playIf you are correct I will pay you $10.00:5Winner!Your bank is now $20Would you like to continue? (y/n)yPlease enter your guess for the next roll. It only costs $1.00 to playIf you are correct I will pay you $10.00:3Sorry you lose. The dice rolled 1Your bank is now $19Would you like to continue? (y/n)yPlease enter your guess for the next roll. It only costs $1.00 to playIf you are correct I will pay you $10.00:2Sorry you lose. The dice rolled 3Your bank is now $18Would you like to continue? (y/n)nThanks for PlayingYour bank is now $18INCLUDE asmlib.inc
.data prompt BYTE “Welcome to the dice guess game. it costs $1.00 to play. “,0 ;outputs messageprompt2 BYTE “Would you like to continue? (y/n) “,0 ;outputs message to continueprompt3 BYTE “Please enter your guess for the next roll. It only costs $1.00 to play “,0 ;message to the playerprompt4 BYTE “If you are correct I will pay you $10.00:”,0 ;message to the playerOutpW BYTE “Winner!”,0 ;Winner mesaageOutpL BYTE “Sorry you lose. The dice rolled “,0 ;Sorry messageOutp BYTE “Your bank is now $”,0 ;shows bank accountprompt5 BYTE “Thanks for playing “,0 ;outputs thanks messageprompt6 BYTE “Game Over”,0 ;game over messageBank DWORD 10 ;variablerNum DWORD 0 ;variable for stoirng .codemain PROC mov edx, OFFSET prompt ;outputs messagecall writeLine ;writes to screenendl ;endlinemov ecx, 5 ;moves ecx to 5mov eax, 0 ;moves eax to 0call randSeedmov edx, OFFSET prompt2 ;moves edx to output messagecall writeString ;writes to screencall readChar ;reads inputL1: ;loop.IF al == ‘y’ ;conditional mov edx, OFFSET prompt3 ;if true output messagecall writeLine ;write to screenendl ;endline.ELSE jmp EXITOUT ;else jump to exit.ENDIFmov eax, 6 ;moves to eaxcall randRange ;calls random rangeinc eax ;increments eax by 1mov rNum, eax ;moves rNum to eaxmov edx, OFFSET prompt4 ;moves edx to promptcall writeLine ;writes message to screencall readInt ;reads input.IF eax != rNum; conditionalmov edx, OFFSET OutpL ;noves message to edxcall writeString ;writes to screencall writeInt ;writes numebr to screenendl ;ends linemov edx, OFFSET Outp;moves to edx outputs messagecall writeString ;writes to screenmov eax, Bank ;moves eax to bankdec eax ;decremnts bankcall writeInt ;writes to screenmov edx, OFFSET prompt2 ;moves to edx to output messagecall writeString ;writes to screencall readChar ;reads input.ELSEmov edx, OFFSET OutpW ;outputs messagecall writeString ;writes to screemmov edx, OFFSET Outp ;outputs messagecall writeString ;writes to screemmov eax, 10 ;moves 10 to eaxadd eax, Bank ;adds 10 to bankcall writeInt ;writes numebr to screenmov edx, OFFSET prompt2 ;moves edx to output messagecall writeString ;writes to screencall readChar ;reads input.ENDIF ;ends if.IF Bank == 0 ;conditional to check if bank is eqaul to 0mov edx, OFFSET prompt6 ;outputs message to screencall writeLine ;writes message to screen.ENDIF; ends ifJMP L1; jumps back to L1EXITOUT: ;Exitout labelmov edx, OFFSET prompt5 ;;outputs message to screencall writeString ;writes to screenexit main ENDP END main