clc clear load Dice;%load the picture of the dice fprintf('Welcome to the game Over 7/Under 7\n')%welcome the user currentPool = input('Please enter the amount of money you want to put in the pool: ');%prompt the user to input the money they want to put in the pool while currentPool ~= 0%keep running the game if there is money in the pool fprintf('\nYou have %f dollars',currentPool)%remind the user the money in the pool bet = input('\nEnter an amount to bet (0 to quit): ');%prompt the user to input the money they want to bet in this round if bet ~= 0 while bet > currentPool || bet < 0%evalute the situation when user bet lower than 0 or greater than the pool fprintf('\nYour bet MUST between 0 and %f dollars',currentPool)%warn the user with the message fprintf('\nYou have %f dollars',currentPool) bet = input('\nEnter an amount to bet (0 to quit): ');%prompt the user again to input the money they want to bet in this round end end if bet == 0 fprintf('You have %f dollars left.',currentPool) break%end the while loop in this situation end highLow = input('High, low or sevens (H/L/S): ','s');%prompt the user for guess high/low roll = randi([1 6],[1 2]);%roll the 2 dice imshow([Dice{roll}])%show the picture of the dice total = roll(1) + roll(2);%add the two dice fprintf('Total of two dice is %.0f',total)%print the two dice to screen winnings = 0;%initialize the winnings to 0 if highLow == 'H' || highLow == 'h'%if the user guess High if total >= 8 winnings = bet;%1 time the winnings else winnings = -1 * bet;%minus the money bet end elseif highLow == 'S' || highLow == 's'%if the user guess Sevens if total == 7 winnings = 4 * bet;%4 times the winnings else winnings = -1 * bet;%minus the money bet end elseif highLow == 'L' || highLow == 'l'%if the user guess Low if total <= 6 winnings = bet;%1 time the winnings else winnings = -1 * bet;%minus the money bet end end if winnings < 0%determine if the user wins fprintf('\nYou lost!')%user lost if winning is less than 0 else fprintf('\nYou won %f dollars',winnings)%user won if winning is larger than 0, and print the winnings to screen end currentPool = currentPool + winnings;%update the current pool with the winnings end fprintf('\nGoodbye!')%goodbye to user when end the game