fork download
  1. #include <math.h>
  2. #include <iostream>
  3. #include <string>
  4. int int1, int2, answer;
  5. bool bValue(true);
  6. std::string oper;
  7. std::string cont;
  8. using namespace std;
  9. std::string typeOfMath;
  10. int a;
  11. int b;
  12. int answerExponent;
  13.  
  14.  
  15. int main(int argc, const char * argv[])
  16. {
  17.  
  18. // Taking user input, the first number of the calculator, the operator, and second number. Addition, Substraction, Multiplication, Division
  19. cout<<"______________________________________________\n";
  20. cout<<"|Welcome to The ExpCalc! Do you want to do |\n";
  21. cout<<"|Exponent Math, or Basic Math(+, -, X, %) |\n";
  22. cout<<"|Type in 'B' for basic Math, and'E' for |\n";
  23. cout<<"|Exponential Math! Enjoy! (C) John L. Carveth|\n";
  24. cout<<"|____________________________________________|\n";
  25. cin>> typeOfMath;
  26. if(typeOfMath == "Basic" ||
  27. typeOfMath == "basic" ||
  28. typeOfMath == "b" ||
  29. typeOfMath =="B")
  30. {
  31. cout << "Hello! Please Type in your first integer!\n";
  32. cin>> int1;
  33. cout<<"Great! Now Enter your Operation: ex. *, /, +, -...\n";
  34. cin>> oper;
  35. cout<<"Now all we need is the last int!\n";
  36. cin>> int2;
  37.  
  38. if (oper == "+") {
  39. answer = int1 + int2;
  40. }
  41. if (oper == "-") {
  42. answer = int1 - int2;
  43.  
  44. }if (oper == "*") {
  45. answer = int1 * int2;
  46. }if (oper == "/") {
  47. answer = int1 / int2;
  48. }
  49. cout<<answer << "\n";
  50. cout<<"Thanks for Using The ExpCalc!\n";
  51.  
  52.  
  53. }
  54.  
  55.  
  56.  
  57. else if(typeOfMath == "Exp" ||typeOfMath == "E" ||typeOfMath == "e" ||typeOfMath == "Exponent"){
  58. cout<<"Enter the desired Base. Example: 2^3, where 2 is the base.\n";
  59. cin>> a;
  60. cout<<"Now what is the desired exponent/power of the base? Ex. 2^3 where 3 is the exponent!\n";
  61. cin>>b;
  62. answerExponent = (pow(a,b));
  63. cout<< answerExponent;
  64. } else(cout<<"Wrong String!");
  65. }
Success #stdin #stdout 0s 3036KB
stdin
e
2
3
stdout
______________________________________________
|Welcome to The ExpCalc! Do you want to do   |
|Exponent Math, or Basic Math(+, -, X, %)    |
|Type in 'B' for basic Math, and'E' for      |
|Exponential Math! Enjoy! (C) John L. Carveth|
|____________________________________________|
Enter the desired Base. Example: 2^3, where 2 is the base.
Now what is the desired exponent/power of the base? Ex. 2^3 where 3 is the exponent!
8