// Name:  McCabe, Micheal H.
// Date:  March 16, 2009
// Calc_V2.cpp

// List of library functions needed.

#include <iostream>
#include <string>
#include <iomanip>
#include <fstream>
#include <cstdlib>
#include <cmath>

// Namespace definitions, etc.

using namespace std;

// Compiler definitions

#define MAX_USER_LIST 100
float Data[MAX_USER_LIST];

#define N1			Data[1]
#define N2			Data[2]
#define USER_ENTRIES	Data[0]
#define START_USER_DATA	3

#define HELP_e 		    "	'e'  to enter N1 and N2\n"
#define HELP_i		    "	'i'  to enter a list of values (Q to stop)\n"
#define HELP_fi         "	'fi' File input:  prompt for a filename and read values into list [] \n";
#define HELP_fo         "	'fo' File Output: prompt for a filename and write list values out. \n";
#define HELP_plus       "	'+'  Add (N1 + N2) \n";
#define HELP_minus      "	'-'  Subtract (N1 - N2) \n";
#define HELP_star       "	'*'  Multiply (N1 * N2) \n";
#define HELP_slash      "	'/'  Divide (N1 / N2) \n";
#define HELP_caret  	"   '^'  Raise any real N1 to the power of N2 for any integer N2 (+|-) \n";
#define HELP_exclaim    "	'!'  Calculate the factorial for any integer N1 (round if real) \n";
#define HELP_c          "	'c'  Clear (N1, N2) \n";
#define HELP_cL         "	'cL' Clear the memory list of all values. \n";
#define HELP_h          "	'h'  Help \n";
#define HELP_l          "	'l'  List all the values currently in List () \n";
#define HELP_q          "	'q'  Quit \n";
#define HELP_o          "	'o'  Output the last calculation results to the screen. \n";
#define HELP_a          "	'a'  Average of the values in list [] \n";
#define HELP_d          "	'd#' Delete the value at the index # in List [] \n";
#define HELP_m          "	'm#' Memorize (save) the last calculation result at index # in list. \n";
#define HELP_s          "	's'  Sum all the values in List [] \n";
#define HELP_sd         "	'sd' Calulate the standard deviation in the list [] \n";
#define HELP_p          "	'p'  Calculate the product of the values in the list \n";
#define HELP_M1         "	'M1' Prompt for index '#' and store N1 into list[#] \n";
#define HELP_M2         "	'M2' Prompt for index '#' and store N2 into list[#] \n";
#define HELP_N1          "	'N1' Prompt for index '#' and store List[#] into N1 \n";
#define HELP_N2         "	'N2' Prompt for index '#' and store List[#] into N2 \n";
#define NO_COMMAND	    "        No command recognized\n"

// Function prototypes

void help_function();

// Main Routine

int main()
{
bool command_loop = true;
char cmd_chr1;
string temp;

while (command_loop)
	{
	cin.get(cmd_chr1);
	
	// Decode it
	
	switch (cmd_chr1)
	{
		case 'e':
			temp = HELP_e;
			break;
		case 'i':
			temp = HELP_i;
			break;
		case 'f':
             //temp = HELP_fi + HELP_fo;
             cout << HELP_fi;
             cout << HELP_fo;
             temp="";
             break;
        case '+':
             temp = HELP_plus;
             break;
        case '-':
             temp = HELP_minus;
             break;
        case '*':
             temp = HELP_star;
             break;
        case '/':
             temp = HELP_slash;
             break;
        case '^':
             temp = HELP_caret;
             break;
        case '!':
             temp = HELP_exclaim;
             break;
        case 'c':
             //temp = HELP_c + HELP_cL;
             cout << HELP_c;
             cout << HELP_cL;
             temp="";
             break;
        case 'h':
             help_function();
             temp = "";
             break;
        case 'l':
             temp = HELP_l;
             break;
        case 'q':
             command_loop = false;
             temp = "Bye, Bye!";
             break;
        case 'o':
             temp = HELP_o;
             break;
        case 'a':
             temp = HELP_a;
             break;
        case 'd':
             temp = HELP_d;
             break;
        case 'm':
             temp = HELP_m;
             break;
        case 's':
             //temp = HELP_s + HELP_sd;
             cout << HELP_s;
             cout << HELP_sd;
             temp="";
             break;
        case 'p':
             temp = HELP_p;
             break;
        case 'M':
             //temp = HELP_M1 + HELP_M2;
             cout << HELP_M1;
             cout << HELP_M2;
             temp="";
             break;
        case 'N':
             //temp = HELP_N1 + HELP_N2;
             cout << HELP_N1;
             cout << HELP_N2;
             temp="";
             break;
		default:
			temp = "NO_COMMAND \n";
	}		
	cout << temp;
	
	// Clear current line out
	cin.ignore(100, '\n');
	}
}

void help_function()
{
     cout << HELP_h;
}


