Guest User

Untitled

a guest
May 22nd, 2018
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1. #include <iostream>
  2. #include <cmath>
  3. #include <cstdlib>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. void ab();
  9. void c();
  10.  
  11. int main()
  12. {
  13. for(;;){
  14. cout << "Pythagoras Calculator - By Colin Berry\n";
  15. cout << "A or B - 1\n";
  16. cout << "C - 2\n";
  17. cout << "Quit - 99\n";
  18. int ans;
  19. cin >> ans;
  20. switch(ans){
  21. case 1:
  22. ab();
  23. break;
  24. case 2:
  25. c();
  26. break;
  27. case 99:
  28. return 1;
  29. }
  30. }
  31. }
  32. void ab(){
  33. cout << "Enter value of C\n";
  34. double c;
  35. cin >> c;
  36. cout << "Enter value of A/B\n";
  37. double a;
  38. cin >> a;
  39. double d;
  40. double end;
  41. a = a*a;
  42. c = c*c;
  43. d = c - a;
  44. end = sqrt(d);
  45. cout << "Line is " << setprecision(2) << fixed << end << endl;
  46. system("PAUSE");
  47. }
  48. void c(){
  49. cout << "Enter value of A\n";
  50. double a;
  51. cin >> a;
  52. cout << "Enter value of B\n";
  53. double b;
  54. cin >> b;
  55. double c;
  56. double end;
  57. a = a*a;
  58. b = b*b;
  59. c = a + b;
  60. end = sqrt(c);
  61. cout << "Line C is " << setprecision(2) << fixed << end << endl;
  62. system("PAUSE");
  63. }
Add Comment
Please, Sign In to add comment