<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. START
  3. Sets betcost4 and betnum4 to 66
  4. assigns the various betnum and betcost to variables
  5. generates a random number synced to the time
  6.    WHILE bet is less than 4
  7.    spin  is assigned to a random number generated between 0 and 37
  8.    END WHILE
  9.       IF the betnum or betcost is equal to 66 then an error message is printed
  10.       ELSE IF the betnum or betcost variables are greater than 37 an error message is printed
  11.       ELSE IF the betnum or betcost variables are less than 0 an error message is printed
  12.       ELSE IF the betcost variavles are less than 0 an error message is printed
  13.          WHILE betnum is less than 4
  14.       IF the betnum is the same as the Spin
  15.       THEN the winnings received are equal to the current total, plus the betcost multiplied by 36
  16.          END WHILE
  17. total is calculated and printed by adding the winnings and losses together
  18. END
  19. */
  20.  
  21.  
  22.  
  23.  
  24. #include <stdio.h>
  25. #include <stdlib.h>
  26. #include <time.h>
  27.  
  28. int main(void)
  29. {
  30.    int Spin1, Spin2, Spin3, Spin4;
  31.    int betnum1, betnum2, betnum3, betnum4, betcost1, betcost2, betcost3, betcost4;
  32.    int total;
  33.    
  34.    betnum4 = 66;/*Lines 24 and 25 are used for the error message if no input is detected*/
  35.    betcost4 = 66;
  36.    
  37.    scanf( "%d %d %d %d %d %d %d %d", &betnum1, &betcost1, &betnum2, &betcost2, &betnum3, &betcost3, &betnum4, &betcost4 );/*Organising the betnum and betcost integers into pairs to work with the input requirements*/
  38.    
  39.    srand( time(0) );
  40.    
  41.    Spin1 = rand() %38;/*Assigning the 'spin' as being a randomly generated number between 0 and 37*/
  42.    Spin2 = rand() %38;
  43.    Spin3 = rand() %38;
  44.    Spin4 = rand() %38;
  45.  
  46.   if (betnum4 == 66 || betcost4 == 66)
  47.   printf ("Input error, please use a pair of inputs consisting of betnums of 0-36 and a betcost of 1 and above");/*The "catch all" error message that triggers if a valid input is detected, this includes not enough inputs being detected, a betcost of negative numbers and bet numbers of negative numbers*/
  48.   else if( betnum1 > 37 || betnum2 > 37 || betnum3 > 37 || betnum4 > 37)
  49.   printf("You chose a number over 37, try a valid number between 0 and 37");/*This is an error message that triggers if a number greater than 37 is read*/
  50.   else if( betnum1 < 0 || betnum2 < 0 || betnum3 < 0 || betnum4 < 0)
  51.   printf( "You chose a number less than 0, try a valid number between 0 and 36");/*This is an error message that triggers if a number less than 0 is read*/
  52.   else if (betcost1 < 0 || betcost2 < 0 || betcost3 < 0 || betcost4 < 0)
  53.   printf( "You tried to bet with 0 or less cash, try actually betting something now");/*This is an error message that triggers if a 'betcost' of 0 is detected*/
  54.   else
  55.   {
  56.    if (betnum1 == Spin1)
  57.       {total = total+betcost1*36;
  58.    printf("You won!\nYour bet number was %d\nYour bet ammount was %d\nThe winning number was %d\nThe payout value is %d \nYour subtotal of winnings and losses are %d\n\n", betnum1, betcost1, Spin1, betcost1*36, total);
  59.    }
  60.    else
  61.      {total = total-betcost1;
  62.    printf("You lost, try again!\n\n");
  63.    }
  64.    if (betnum2 == Spin2)
  65.       {total = total+betcost2*36;
  66.    printf("You won!\nYour bet number was %d\nYour bet ammount was %d\nThe winning number was %d\nThe payout value is %d \nYour subtotal of winnings and losses are %d\n\n", betnum2, betcost2, Spin2, betcost2*36, total);
  67.    }
  68.    else
  69.       {total = total-betcost2;
  70.    printf("You lost, try again!\n\n");
  71.    }
  72.    if (betnum3 == Spin3)
  73.       {total = total+betcost3*36;
  74.    printf("You won!\nYour bet number was %d\nYour bet ammount was %d\nThe winning number was %d\nThe payout value is %d \nYour subtotal of winnings and losses are %d\n\n", betnum3, betcost3, Spin3, betcost3*36, total);
  75.    }
  76.    else
  77.       {total = total-betcost3;
  78.    printf("You lost, try again!\n\n");
  79.    }
  80.    if (betnum4 == Spin4)
  81.       {total = total+betcost4*36;
  82.    
  83.    printf("You won!\nYour bet number was %d\nYour bet ammount was %d\nThe winning number was %d\nThe payout value is %d \nYour subtotal of winnings and losses are %d\n\n", betnum4, betcost4, Spin4, betcost4*36, total);
  84.    }
  85.    else
  86.       {total = total-betcost4;
  87.    printf("You lost, try again!\n\n");
  88.    }
  89.    printf("Your total ammount of winnings and losses overall are %d", total);
  90.    }
  91.    }