Advertisement
Guest User

Untitled

a guest
Nov 26th, 2014
171
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #include <cstdlib>
  2. #include <iostream>
  3. #include <math.h>
  4. #define RADTODEG(Rad) ((180.0 * Rad) / PI)
  5. #define PI 3.14159
  6.  
  7. using namespace std;
  8.  
  9. int main(int argc, char *argv[])
  10.  
  11. {
  12.    float a;
  13.    float b;
  14.    float c;
  15.    float d; //angle
  16.    float e; //opposite
  17.    float f;
  18.    float g;
  19.    float h;
  20.    int n;
  21.    int i;
  22.    unsigned long long factorial;
  23.    int o;
  24.    
  25.     cout << "Please select on of the following options \n 1. Calculate the circumference of a circle \n 2. The area of a circle \n 3. The Hypotenuse of a triangle and the Opposite \n 4. Calculate the factorial of a Number.\n";
  26.     cin >> a;
  27.    
  28.     if (a==1){
  29.        cout << "Please Input the radius of the Circle\n";
  30.        cin >> b;
  31.        c = (2*PI*b);
  32.        cout << "The Circumference of the circle is :";
  33.        cout << c;
  34.        }
  35.     else if (a==2){
  36.        cout << "Please Input the radius of the Circle\n";
  37.        cin >> b;
  38.        c = (PI*(b*b));
  39.        cout << "The Area of the circle is :";
  40.        cout << c;
  41.        }
  42.     else if (a==3){
  43.        cout << "Please input Angle";
  44.        cin >> d;
  45.        cout << "Please input Opposite";
  46.        cin >> e;
  47.        g = sin(d*PI/180);
  48.        h = (e/g);
  49.        cout << h;
  50.        }
  51.        //IAN AFTER THIS POINT IS WHERE I NEED TO PUT IT  
  52.     else if (a==4){
  53.         cout << "Please input a number: ";
  54.         cin >> n;
  55.  
  56.         if (n < 1)
  57.         {
  58.             cout << "Sorry, number must be positive.\n";
  59.         }
  60.         else if (n > 65)
  61.         {
  62.             cout << "Sorry, can't handle a number bigger than 65 with only 64 bits for the result\n";
  63.         }
  64.         else
  65.         {
  66.             factorial=1;
  67.             for (i=n; i>0; i--)
  68.             {
  69.                 factorial *= i;
  70.             }
  71.             cout << "The factorial of " << n << " is " << factorial << "\n";
  72.         }
  73.     else cout << "Incorrect Input";
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement