Advertisement
Guest User

Untitled

a guest
Aug 20th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.82 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. if (mode >= 5)
  29. {
  30. cout << "reached second if statement\n";
  31. mode = 0; // when you get to case 4 in switch(mode) and mode increments, you will
  32. } // activate this if statement and change mode to 0, automatically entering
  33. // the defaults of both switch(selection) and switch(mode)
  34.  
  35. switch(mode)
  36. {
  37. case 1:
  38. {
  39. cout << "Reached case 1.\n";
  40. mode++;
  41. break;
  42. }
  43. case 2:
  44. {
  45. cout << "Reached case 2.\n";
  46. mode++;
  47. break;
  48. }
  49.  
  50. case 3:
  51. {
  52. cout << "Reached case 3.\n";
  53. mode++;
  54. break;
  55. }
  56.  
  57. case 4:
  58. {
  59. cout << "Reached case 4.\n";
  60. mode++;
  61. break;
  62. }
  63. case 5:
  64. {
  65. //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
  66. cout << "Reached case 5.\n";
  67. mode++;
  68. break;
  69. }
  70. case 6:
  71. {
  72. cout << "Reached case 6.\n";
  73. mode = 1;
  74. break;
  75. }
  76. default: cout << "You have reached the default case of switch(mode). Mode is: " << mode << "\n"; break;
  77. }
  78. }
  79. default: cout << "Reached 'default' of switch(selection). Mode is: " << mode << "\n\n"; break;
  80. }
  81. } while(mode < 7);
  82. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement