Advertisement
NovaKun

Nova's Basic C++ Calculator

Mar 10th, 2020
166
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.67 KB | None | 0 0
  1. // Nova's C++ Calculator v1.1
  2. /*
  3. Updates and other information
  4.  
  5. [NEW]**
  6. - Tried using switches for math, might just do separate "if functions" if problem persists.
  7.  
  8. [BUGS]**
  9. - Only multiplication works at the moment.
  10. - Line 45
  11. */
  12. #include <iostream>
  13. #include <string>
  14.  
  15. int main()
  16. {
  17. double digit1;
  18. double digit2;
  19. int process;
  20. double answer;
  21. //information gathering process
  22. std::cout << "Simple Calculator by Nova\n";
  23. std::cout << "Please enter your first number: ";
  24. std::cin >> digit1; //grabbing digit1 from user
  25. std::cout << "\n";
  26. std::cout << "Please enter your second number: ";
  27. std::cin >> digit2; //grabbing second digit
  28. std::cout << "\n";
  29. //menu
  30. std::cout << "--------------------------------\n";
  31. std::cout << "1 - Multiply\n";
  32. std::cout << "2 - Divide\n";
  33. std::cout << "3 - Add\n";
  34. std::cout << "4 - Subtract\n";
  35. std::cout << "--------------------------------";
  36. std::cout << "\n";
  37. std::cout << "Please select a process using a single digit: ";
  38. std::cin >> process;
  39. std::cout << "\n";
  40. if (process >= 5 || process < 1)
  41. {
  42. //Invalid Value Error [BUG 1 - LINE 45]
  43. std::cout << "[Error: Invalid Selection]\n";
  44. std::cout << "\n";
  45. std::cout << "Please select a process using a single digit: ";
  46. std::cout << "[WARNING] If you select a number that isn't on the list, the program will exit. (Currently working on a fix.";
  47. std::cin >> process;
  48. }
  49.  
  50. if (process = 1) {
  51.  
  52. answer = (digit1 * digit2);
  53. std::cout << "Answer: " << answer << "\n";
  54. std::cout << "Run the program again to restart the process.";
  55.  
  56. digit1++;
  57. digit2++;
  58.  
  59. } switch (process = 2) {
  60.  
  61. answer = (digit1 / digit2);
  62. std::cout << "Answer: " << answer << "\n";
  63. std::cout << "Run the program again to restart the process.";
  64.  
  65. digit1++;
  66. digit2++;
  67.  
  68. } switch (process = 3) {
  69. if (process = 3){
  70.  
  71. answer = (digit1 + digit2);
  72. std::cout << "Answer: " << answer << "\n";
  73. std::cout << "Run the program again to restart the process.";
  74.  
  75. digit1++;
  76. digit2++;
  77. } switch (process = 4) {
  78.  
  79. answer = (digit1 - digit2);
  80. std::cout << "Answer: " << answer << "\n";
  81. std::cout << "Run the program again to restart the process.";
  82.  
  83. digit1++;
  84. digit2++;
  85.  
  86. }
  87.  
  88.  
  89. }
  90.  
  91. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement