Advertisement
Guest User

1st test of calculator wizard

a guest
Feb 20th, 2019
95
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.24 KB | None | 0 0
  1. // this is an easy calculator with source code for you guys
  2. // i commented all of this for starters of c++
  3. // this calculator is able to add, subtract, multiply and divide
  4.  
  5. // [includes]
  6.  
  7. #include <iostream>
  8. #include <windows.h>
  9. #include <string>
  10.  
  11. // [includes]
  12.  
  13. // [namespaces]
  14.  
  15. using namespace std;
  16. using std::cout; // more information
  17. using std::cin; // more information
  18.  
  19. // [namespaces]
  20.  
  21. // [variables]
  22.  
  23. float variable1_add; // number 1 for add option
  24. float variable2_add; // number 2 for add option
  25.  
  26. int variable1_substract; // number 1 for substract option
  27. int variable2_substract; // number 2 for substract option
  28.  
  29. int variable1_multiply; // number 1 for multiply option
  30. int variable2_multiply; // number 2 for multiply option
  31.  
  32. int variable1_divide; // number 1 for divide option
  33. int variable2_divide; // number 2 for divide option
  34.  
  35. float total_add; // total for add
  36. int total_substract; // total for substract
  37. int total_multiply; // total for multiply
  38. int total_divide; // total for divide
  39.  
  40. char switch_count; // with this you can choose types
  41.  
  42. string show_options; // i think thats self explanatory
  43. string choose_type; // i think thats self explanatory
  44.  
  45.  
  46. // [variables]
  47.  
  48. // [main class]
  49.  
  50. int main()
  51. {
  52. cout << "Show options?\a" << endl; // shows the options
  53.  
  54. cin >> show_options; // you can choose options there
  55.  
  56. cout << "Here you see the different variants of this calculator. Choose a type and tell me the number" << endl; // shows the 4 options
  57.  
  58. cout << endl; // just a new line
  59.  
  60. // you see the following options down below
  61.  
  62. // first number to choose then description
  63.  
  64. cout << endl; // just a new liner
  65. cout << "WARNING: If you will use point numbers write with a dot: ." << endl;
  66. cout << "(1) Add" << endl; // with this type you can add two variables
  67. cout << "(2) Substract" << endl; // with this type you can substract two variables
  68. cout << "(3) Multiply" << endl; // with this type you can multiply two variables
  69. cout << "(4) Divide" << endl; // with this type you can divide two variables
  70.  
  71. cin >> switch_count; // here you can choose options
  72.  
  73. switch (switch_count) // this is the option menu for the 4 options above
  74. {
  75. case('1'): // add option
  76. {
  77.  
  78. cout << "You have chosen add" << endl;
  79.  
  80. cout << endl;
  81. cout << "Tell me the first number" << endl;
  82. cin >> variable1_add;
  83. cout << "Thanks for telling me the first number (" << variable1_add << "). Now tell me the second number" << endl;
  84. cin >> variable2_add;
  85. cout << "Now adding " << variable1_add << " and " << variable2_add << "." << endl;
  86.  
  87. total_add = variable1_add + variable2_add;
  88. cout << endl;
  89. cout << "The total is: " << total_add << endl;
  90.  
  91. Sleep(500);
  92.  
  93. } break;
  94.  
  95. case('2'): // substract option
  96. {
  97. cout << "You have chosen substract" << endl;
  98. } break;
  99.  
  100. case('3'): // multiply option
  101. {
  102. cout << "You haven chosen multiply" << endl;
  103.  
  104. } break;
  105.  
  106. case('4'): // divide option
  107. {
  108. cout << "You have chosen divide" << endl;
  109.  
  110. } break;
  111. default:
  112. {
  113. cout << "ERROR - Programm will close in 5sec" << endl;
  114. Sleep(5000); // with this command we can close the programm
  115. }
  116.  
  117. }
  118.  
  119. cout << endl;
  120. cout << "Thanks you for using wizard's Calculator" << endl;
  121. Sleep(10000);
  122. }
  123. // [main class]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement