<mosaic.cnfolio.com>
PROGRAM
  1. /*
  2. Start
  3. Label variables(bet,winningN,number,winnings,losses,NetProf)
  4. read inputs
  5. IF the double zero is equal to input
  6.    convert the input to integer
  7. END IF   
  8. IF the input for bet is 0 or less or number bet on is less than 0 or more than 37
  9.    display error
  10. END IF
  11. spin wheel (random number)
  12. display winningN
  13.   IF the wheel lands on same number as bet
  14.      multiply bet amount by 36
  15.      sum equals winnings
  16.      display winnings
  17.      add winnings to net profit
  18.      subtract bet amount from net profit
  19.   ELSE IF
  20.      display losses
  21.      add losses to net loss
  22.   END IF   
  23. display net profit
  24. display net loss
  25. display change in wallet amount
  26. End
  27. */
  28.  
  29. #include <stdio.h>
  30. #include <stdlib.h>
  31. #include <time.h>
  32. #include <string.h>
  33.  
  34. int main ( void )
  35. {
  36. int bet1=0;
  37. int bet2=0;
  38. int bet3=0;
  39. int bet4=0;
  40. int winnings1=0;
  41. int losses1=0;
  42. int winnings2=0;
  43. int losses2=0;
  44. int winnings3=0;
  45. int losses3=0;
  46. int winnings4=0;
  47. int losses4=0;
  48. int number1=37;
  49. int number2=37;
  50. int number3=37;
  51. int number4=37;
  52. int winningN;
  53. int NetProf=0;
  54. int NetLoss=0;
  55. char num1z[2];//define number as character for comparison later
  56. char num2z[2];
  57. char num3z[2];
  58. char num4z[2];
  59. char twoz[]="00";//define double zero as character
  60.  
  61. scanf("%s %d %s %d %s %d %s %d", &num1z, &bet1, &num2z, &bet2, &num3z, &bet3, &num4z, &bet4);
  62.  
  63. if(strncmp(twoz,num1z,2))//compares two strings, if strings are the same converts alphabet to integer
  64.   {
  65.   number1=atoi(num1z);
  66.   }
  67. if(strncmp(twoz,num2z,2))//the 2 represents the two characters, 00
  68.   {
  69.   number2=atoi(num2z);
  70.   }
  71. if(strncmp(twoz,num3z,2))
  72.   {
  73.   number3=atoi(num3z);
  74.   }
  75. if(strncmp(twoz,num4z,2))
  76.   {
  77.   number4=atoi(num4z);
  78.   }   
  79.        
  80. if ((bet1 <= 0)||(bet2 <= 0)||(bet3 <= 0)||(bet4 <= 0)||(number1>37)||(number2>37)||(number3>37)||(number4>37)||(number1<0)||(number2<0)||(number3<0)||(number4<0))
  81.    {
  82.    printf("ERROR, numbers bet on must be between 00 and 36\nand bets must be above 0 \nMust also be 8 inputs");
  83.    exit(0);//shorter than an if statement
  84.    }
  85.  
  86. printf("\nFirst bet is $%d on %s  \nSecond bet is $%d on %s  \nThird bet is $%d on %s  \nFourth bet is $%d on %s ",bet1, num1z, bet2, num2z, bet3, num3z, bet4, num4z);
  87.  
  88. srand(time(NULL));//initialise the number generator randomise
  89.  
  90. winningN = rand()%38;//38 to account for 00
  91.  
  92. if (winningN==37)//IF 37 is equal to random number then display 00
  93. {
  94. printf("\nthe winning number is 00\n");
  95. }
  96. else
  97. {
  98. printf("\nthe winning number is %d\n" ,winningN);
  99. }
  100. if (number1 == winningN)
  101.    {
  102.    winnings1 = bet1*36;//payout value not profit
  103.    printf("\n$%d was won from bet one\n",winnings1);
  104.    NetProf=NetProf+winnings1-bet1;//subtract bet to give the profit
  105.    losses1=bet1;
  106.    }
  107.    
  108.    else
  109.    {
  110.    losses1=-1*bet1;
  111.    winnings1=0;
  112.    printf("\nNothing was won from bet one",winnings1);
  113.    printf("\n$%d was lost from bet one\n", losses1);
  114.    NetLoss=NetLoss+losses1;
  115.    }
  116.    
  117. if (winningN == number2)
  118.    {
  119.    winnings2 = bet2*36;
  120.    printf("\n$%d was won from bet two\n",winnings2);
  121.    NetProf=NetProf+winnings2-bet2;//could be bet times 35 but may skew the method for others
  122.    losses2=bet2*-2;
  123.    }
  124.    
  125.    else
  126.    {
  127.    losses2=-1*bet2;
  128.    winnings2=0;
  129.    printf("\nNothing was won from bet two",winnings2);
  130.    printf("\n$%d was lost from bet two\n", losses2);
  131.    NetLoss=NetLoss+losses2;
  132.    }
  133.    
  134. if (winningN == number3)
  135.    {
  136.    winnings3 = bet3*36;
  137.    printf("\n$%d was won from bet three\n",winnings3);
  138.    NetProf=NetProf+winnings3-bet3;
  139.    losses3=bet3*-1;
  140.    }
  141.    else
  142.    {
  143.    losses3=-1*bet3;
  144.    winnings3=0;
  145.    printf("\nNothing was won from bet three",winnings3);
  146.    printf("\n$%d was lost from bet three\n", losses3);
  147.    NetLoss=NetLoss+losses3;
  148.    }
  149.    
  150. if (winningN == number4)
  151.    {
  152.    winnings4 = bet4*36;
  153.    printf("\n$%d was won from bet four\n",winnings4);
  154.    NetProf=NetProf+winnings4-bet4;
  155.    losses4=bet4*-1;
  156.    }
  157.    else
  158.    {
  159.    losses4=-1*bet4;
  160.    winnings4=0;
  161.    printf("\nNothing was won from bet four",winnings4);
  162.    printf("\n$%d was lost from bet four\n", losses4);
  163.    NetLoss=NetLoss+losses4;
  164.    }
  165.    printf("\nnet profit is $%d", NetProf);
  166.    printf("\nnet loss is $%d", NetLoss);
  167.    printf("\nChange to wallet amount is $%d", NetProf + NetLoss);//net loss is saved as a negative value so plus is used
  168. }