BHXSpecter

My stupidity showing through!

Nov 10th, 2011
222
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.00 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <iomanip>
  4.  
  5. using namespace std;
  6.  
  7. void functionOne();
  8. void functionTwo();
  9. void functionThree();
  10. void functionFour();
  11. void functionFive();
  12. void functionSix();
  13. void functionSeven();
  14. void functionEight();
  15. void functionNine();
  16. void functionTen();
  17.  
  18. int main()
  19. {
  20.     int randNum = 0;
  21.     char ch = 'N';
  22.     bool done = false;
  23.     cout << "This will pick a function at random til you say 'y' or 'Y' for quitting!!!" << endl;
  24.     randNum = rand() % 100;
  25.    
  26.     while (!done)
  27.     {
  28.         if (ch == 'y' || ch == 'Y')
  29.             done = true;
  30.         else
  31.         {
  32.             switch(randNum / 10)
  33.             {
  34.                 case 0:
  35.                     functionOne();
  36.                     break;
  37.                 case 1:
  38.                     functionTwo();
  39.                     break;
  40.                 case 2:
  41.                     functionThree();
  42.                     break;
  43.                 case 3:
  44.                     functionFour();
  45.                     break;
  46.                 case 4:
  47.                     functionFive();
  48.                     break;
  49.                 case 5:
  50.                     functionSix();
  51.                     break;
  52.                 case 6:
  53.                     functionSeven();
  54.                     break;
  55.                 case 7:
  56.                     functionEight();
  57.                     break;
  58.                 case 8:
  59.                     functionNine();
  60.                     break;
  61.                 case 9:
  62.                     functionTen();
  63.                     break;
  64.                 default:
  65.                     cout << "Something went terribly wrong!" << endl;
  66.                     break;
  67.             }
  68.         }
  69.         cout << "Number is: " << randNum << endl;
  70.         cout << "Do you want to quit? (y/n): ";
  71.         cin >> ch;
  72.         cout << endl;
  73.         randNum = rand() % 100;
  74.     }
  75.    
  76.     return 0;
  77. }
  78. void functionOne()
  79. {
  80.     cout << "function one called" << endl;
  81. }
  82. void functionTwo()
  83. {
  84.     cout << "function two called" << endl;
  85. }
  86. void functionThree()
  87. {
  88.     cout << "function three called" << endl;
  89. }
  90. void functionFour()
  91. {
  92.     cout << "function four called" << endl;
  93. }
  94. void functionFive()
  95. {
  96.     cout << "function five called" << endl;
  97. }
  98. void functionSix()
  99. {
  100.     cout << "function six called" << endl;
  101. }
  102. void functionSeven()
  103. {
  104.     cout << "function seven called" << endl;
  105. }
  106. void functionEight()
  107. {
  108.     cout << "function eight called" << endl;
  109. }
  110. void functionNine()
  111. {
  112.     cout << "function nine called" << endl;
  113. }
  114. void functionTen()
  115. {
  116.     cout << "function ten called" << endl;
  117. }
  118.  
  119.  
Advertisement
Add Comment
Please, Sign In to add comment