Guest User

Untitled

a guest
Oct 23rd, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. //Title: Arithmetic Choice
  2. //purpose: Techincally a calculator
  3. //Author: Robert Hewson
  4.  
  5. #include "stdafx.h"
  6. #include <iostream>
  7. #include <conio.h>
  8.  
  9. struct problem
  10. {
  11. double numone;
  12. double numtwo;
  13. char arithmetic;
  14. double answer;
  15. };
  16.  
  17. using namespace std;
  18.  
  19. int main()
  20. {
  21. problem problem1;
  22. cout<<"Please enter the first number."<<endl;
  23. cin>>problem1.numone;
  24. cout<<"Please enter the second number."<<endl;
  25. cin>>problem1.numtwo;
  26. cout<<"Please enter if you want to (a)dd, (s)ubtract, (d)ivide, or (m)ultiply"<<endl;
  27. cin>>problem1.arithmetic;
  28. if(problem1.arithmetic == 'a' )
  29. problem1.answer = problem1.numone + problem1.numtwo;
  30. cout<<"The answer is "<<problem1.answer;
  31. else
  32. {
  33. if(problem1.arithmetic == 's' )
  34. problem1.answer = problem1.numone - problem1.numtwo;
  35. cout<<problem1.answer<<endl;
  36. else
  37. {
  38. if(problem1.arithmetic == 'd' )
  39. problem1.answer = problem1.numone / problem1.numtwo;
  40. cout<<problem1.answer<<endl;
  41. else
  42. {
  43. if(problem1.arithmetic == 'm')
  44. problem1.answer = problem1.numone * problem1.numtwo;
  45. cout<<problem1.answer<<endl;
  46. }
  47. }
  48. }
  49.  
  50. getch();
  51. }
Add Comment
Please, Sign In to add comment