
//   ##################################################
//   ##                                              ##
//   ##                                              ##
//   ##    NECESSARY TO  MACHINE PROBLEM 1           ##
//   ##                                              ##
//   ##                                              ##
//   ##                                              ##
//   ##                                              ##
//   ##                                              ##
//   ##################################################

// Filename: wrap.C
// Author  : Asif Qamar
// Created : Jan31st, 1998



#include <iostream.h>
#include <math.h>
#include <iomanip.h>


static int printMenu(void);


//   ##################################################

//   THESE ARE THE FUNCTIONS THAT YOU 
//   HAVE TO WRITE/IMPLEMENT:
  
//   Read the main() function to get a sense of how
//   you have to implement your functions. A review
//   of Chapters 1-3 of Deitel and Deitel, and the 
//   lecture notes will be very useful.
  

void allTheMeans();
void pythagoreanNumbers(long limit);
double chebyshevPolynomial(double x, int n);
long fibonacci(long n);
double areaOfTriangle(double side1, double side2, double side3);

//    ################################################

int main(void)
{
  char input; 
  while(input= printMenu())          // This loop prints the menu 
  { 
    switch(input)                    // This switch helps decide
    {                                //which function to execute
	case 'A':
	case 'a':
	  {
	    allTheMeans();
	    break;
	  }
	case 'B':
	case 'b':
	  {
	    long limit;
	    cout<<"Enter the limit for Pythagorean numbers: ";
	    cin>>limit;
	    cout<<endl;
	  pythagoreanNumbers(limit);
	  };
	  break;
	case 'C':
	case 'c':
	  {
	    int n=0;
	    double x=0.0;
	    cout<<"Enter the floating point number: ";
	    cin>>x;
	    cout<<"Enter the order of Chebyshev Polynomial: ";
	    cin>>n;
	    cout<<"The "<<n<<"-order Chebyshev Polynomial value of "<<x<<" is "
		<<setprecision(4)
		<<setiosflags(ios::fixed | ios::showpoint)
		<<chebyshevPolynomial(x,n)<<endl;
	  };
	break;
	case 'D':
	case 'd': 
	  {
	    long n;
	    cout<<"Enter the value of n: ";
	    cin>>n;
	    cout<<"\n The Fibonacci number is "<<fibonacci(n)<<endl;
	  };
	  break;
	case 'E':
	case 'e':
	  {
	    double side1, side2, side3;
	    cout<<"Enter a side of the triangle: ";
	    cin>>side1;
	    cout<<"Enter another side of the triangle: ";
	    cin>>side2;
	    cout<<"Enter the third side of the triangle: ";
	    cin>>side3;
	    cout<<"On flat surfaces, the area of the triangle would be "
		<<setprecision(4)
		<<setiosflags(ios::fixed | ios::showpoint)
		<<areaOfTriangle(side1, side2, side3)
		<<endl;
	  };
	break;
	case 'X':
	case 'x':
	  cout<<endl;
	  return 0;
	default:
	  cerr<<"Incorrect input: Choose from A,B,C,D,E,and X"<<endl;
	  break;
	}
    }
return 0;
}


// This function prints the menu from which the 
// makes his choice.
int printMenu(void)
{
char input;
  cout<<"*********************************************\n\n"
      <<"CHOOSE ONE FUNCTION FROM THE MENU  "
      <<"\n\n A:\t All the Mean"
      <<"\n B: \t Pythagorean Number"
      <<"\n C: \t Chebyshev Polynomial"
      <<"\n D: \t Fibonacci Numbers"
      <<"\n E: \t Area of triangle"
      <<"\n X: \t Exit the program"
      <<"\n Enter your choice : ";
  cin>>input;
  return input;                      
}




