Advertisement
EmmettMilligan

CPP Framed Box Calculator

Nov 14th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.04 KB | None | 0 0
  1. cout << "Please enter symbol: ";
  2. char sym;
  3. cin >> sym;
  4. cout<<"Please enter the first number:";
  5. int num1;
  6. cin>>num1;
  7. cout<<"Please enter the operrator:";
  8. char opp;
  9. cin>>opp;
  10. cout<<"Please enter the second number:";
  11. int num2;
  12. cin>>num2;
  13. int wid=10;
  14. int len=50;
  15. cout << endl;
  16.  
  17. for (int a = 1; a <= wid; a++){
  18. for (int b = 1; b <= len; b++)
  19. {
  20. if (a == 1)
  21. cout << sym;
  22. else if (b == 1)
  23. cout << sym;
  24. else if (a == wid)
  25. cout << sym;
  26. else if (b == len)
  27. cout << sym;
  28. else
  29. cout << " ";
  30. }
  31. cout << endl;
  32. }
  33. int answer;
  34. gotoxy(18,9);
  35. if(opp=='+'){
  36. answer=num1 + num2;
  37. cout<<num1<<" + "<<num2<<" = "<<answer;
  38. }
  39. if(opp=='/'){
  40. answer=num1 / num2;
  41. cout<<num1<<" / "<<num2<<" = "<<answer;
  42. }
  43. if(opp=='*'){
  44. answer=num1 * num2;
  45. cout<<num1<<" * "<<num2<<" = "<<answer;
  46. }
  47. if(opp=='-'){
  48. answer=num1 - num2;
  49. cout<<num1<<" - "<<num2<<" = "<<answer;
  50. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement