Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cmath>
- #include <cstdlib>
- #include <iomanip>
- using namespace std;
- void ab();
- void c();
- int main()
- {
- for(;;){
- cout << "Pythagoras Calculator - By Colin Berry\n";
- cout << "A or B - 1\n";
- cout << "C - 2\n";
- cout << "Quit - 99\n";
- int ans;
- cin >> ans;
- switch(ans){
- case 1:
- ab();
- break;
- case 2:
- c();
- break;
- case 99:
- return 1;
- }
- }
- }
- void ab(){
- cout << "Enter value of C\n";
- double c;
- cin >> c;
- cout << "Enter value of A/B\n";
- double a;
- cin >> a;
- double d;
- double end;
- a = a*a;
- c = c*c;
- d = c - a;
- end = sqrt(d);
- cout << "Line is " << setprecision(2) << fixed << end << endl;
- system("PAUSE");
- }
- void c(){
- cout << "Enter value of A\n";
- double a;
- cin >> a;
- cout << "Enter value of B\n";
- double b;
- cin >> b;
- double c;
- double end;
- a = a*a;
- b = b*b;
- c = a + b;
- end = sqrt(c);
- cout << "Line C is " << setprecision(2) << fixed << end << endl;
- system("PAUSE");
- }
Add Comment
Please, Sign In to add comment