Guest User

Untitled

a guest
Jul 19th, 2018
144
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.80 KB | None | 0 0
  1. Calculator in C++
  2.  
  3. #include <cstdlib>
  4. #include <iostream>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. double num;
  11. double num2;
  12. char choice;
  13. for (;;){
  14. do {
  15. cout<<"Welcome to thejoshcalculator. V1.5\n";
  16. cout<<"Please choose an option by entering the number, press q to quit\n";
  17. cout<<"1 - Addition\n";
  18. cout<<"2 - Subtraction\n";
  19. cout<<"3 - Division\n";
  20. cout<<"4 - Multiplication\n";
  21. cout<<"5 - Help\n";
  22. cout<<"6 - About This Program\n";
  23. cout<<"7 - Updates to this program\n";
  24. cin>>choice;
  25. } while ( choice < '1' || choice > '7' && choice != 'q');
  26. if (choice == 'q') break;
  27. switch (choice) {
  28. case '1':
  29. cout<<"Please enter a number\n";
  30. cin>>num;
  31. cout<<"Another number to be added\n";
  32. cin>>num2;
  33. cout<<num + num2;
  34. cout<<"\n";
  35. break;
  36. case '2':
  37. cout<<"Please enter a number\n";
  38. cin>>num;
  39. cout<<"Another number to be subtracted\n";
  40. cin>>num2;
  41. cout<<num - num2;
  42. cout<<"\n";
  43. break;
  44. case '3':
  45. cout<<"Please enter a number\n";
  46. cin>>num;
  47. cout<<"Another one to be divided\n";
  48. cin>>num2;
  49. cout<<num / num2;
  50. cout<<"\n";
  51. break;
  52. case '4':
  53. cout<<"Please enter a number\n";
  54. cin>>num;
  55. cout<<"Another one to be multiplied\n";
  56. cin>>num2;
  57. cout<<num * num2;
  58. cout<<"\n";
  59. break;
  60. case '5':
  61. cout<<"This is a simple calculator made by me - Josh.\n";
  62. cout<<"To select an option, type the number next to the option and press enter\n";
  63. cout<<"E.G. for division, you would type 3 and press enter.\n";
  64. cout<<"\n";
  65. break;
  66. case '6':
  67. cout<<"thejoshcalculator, made by Joshua Griggs - Copyright 2007. :)\n";
  68. cout<<"Feedback would be nice - joshieboy06@hotmail.com also, what programmes\n";
  69. cout<<"do people need. Please give me ideas for programs. Bye!!\n";
  70. cout<<"\n";
  71. break;
  72. case '7':
  73. cout<<"Updates include: -double variable instead of int, so that decimals can be used.\n";
  74. cout<<" -do while loop so that you can exit the program yourself\n";
  75. cout<<"\n";
  76. break;
  77. default:
  78. cout<<"That is not an option";
  79.  
  80. }
  81.  
  82. }
  83. return 0;
  84.  
  85.  
  86. }
Add Comment
Please, Sign In to add comment