Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.61 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4.  
  5. int main()
  6. {
  7. int mode = 0;
  8. int wait = 0; //the wait is to slow down button inputs and i had the same problem before i put that bit in
  9.  
  10. int selection = 0;
  11.  
  12.  
  13. do{
  14. cout << "Enter 99 for 'btnSELECT': " ;
  15. cin >> selection;
  16. switch(selection)
  17. {
  18. case 99: // btnSELECT
  19. {
  20. if (wait == 0)
  21. {
  22. cout << "reached first if statement\n";
  23. cout << "mode is: " << mode << endl;
  24. mode++;
  25. cout << "mode incremented to: " << mode << endl;
  26. wait = 1;
  27.  
  28.  
  29. }
  30. if (mode >= 5)
  31. {
  32. cout << "reached second if statement\n";
  33. mode = 0;
  34.  
  35. }
  36.  
  37. switch(mode)
  38. {
  39. case 1:
  40. {
  41. cout << "Reached case 1.\n";
  42. mode++;
  43. break;
  44. }
  45. case 2:
  46. {
  47. cout << "Reached case 2.\n";
  48. mode++;
  49. break;
  50. }
  51.  
  52. case 3:
  53. {
  54. cout << "Reached case 3.\n";
  55. mode++;
  56. break;
  57. }
  58.  
  59. case 4:
  60. {
  61. cout << "Reached case 4.\n";
  62. mode++;
  63. break;
  64. }
  65. case 5:
  66. {
  67. //only time i got to here was when i added mode++; to the end of case 4 to force it to go to the next 1
  68. cout << "Reached case 5.\n";
  69. mode++;
  70. break;
  71. }
  72. case 6:
  73. {
  74. cout << "Reached case 6.\n";
  75. mode = 1;
  76. break;
  77. }
  78. default: cout << "You have reached the default case of switch(mode). Mode is: " << mode << "\n";
  79. }
  80. break;
  81. default: cout << "Reached 'default' of switch(selection). Mode is: " << mode << "\n\n";break;
  82. }
  83. }
  84. } while(mode < 7);
  85. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement