Advertisement
DRAWNBOX

1337 Calculator

Jun 2nd, 2015
250
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.43 KB | None | 0 0
  1. // Calc1.cpp : Defines the entry point for the console application.
  2. //
  3. #include <iostream>
  4. #include <stdlib.h>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. float input1;
  11. float input2;
  12. int function;
  13. cout << "1 is multiply, 2 is divide, 3 is addition, 4 is subtraction?" << endl;
  14. cin >> function;
  15. if (function == 1)
  16. {
  17. cout << "OK, multiplying" << endl;
  18. cout << "Enter your numbers" << endl;
  19. cin >> input1 >> input2;
  20. cout << "The answer is " << input1*input2 << endl;
  21. }
  22. else if (function == 2){
  23. cout << "OK, dividing" << endl;
  24. cout << "Enter your numbers" << endl;
  25. cin >> input1 >> input2;
  26. cout << "The answer is " << input1 / input2 << endl;
  27. }
  28. else if (function == 3){
  29. cout << "OK, adding" << endl;
  30. cout << "Enter your numbers" << endl;
  31. cin >> input1 >> input2;
  32. cout << "The answer is " << input1 + input2 << endl;
  33. }
  34. else if (function == 4){
  35. cout << "OK, dividing" << endl;
  36. cout << "Enter your numbers" << endl;
  37. cin >> input1 >> input2;
  38. if (input2 == 0)
  39. {
  40. cout << "Your a noob and cant divide by 0" << endl;
  41. system("PAUSE");
  42. }
  43. else if (input2 > 0)
  44. {
  45. cout << "The answer is " << input1 / input2 << endl;
  46. system("PAUSE");
  47. }
  48.  
  49. }
  50. system("PAUSE");
  51. return 0;
  52. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement