// Name:  McCabe, Micheal H.
// Date:  March 16, 2009
// calc_v3.cpp (In-Class Edits & Modifications)

// 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"
#define CMD_PROMPT   "Enter Command: "

// Function prototypes

void help_function();
bool IsDigit(char chr2);
int ReadInputFile(index, List);

// Main Routine

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

while (command_loop)
	{
    cout << CMD_PROMPT;
	cin.get(cmd_chr1);
	cin.get(cmd_chr2);
	
	// Decode it
	
	switch (cmd_chr1)
	{
		case 'e':
			temp = HELP_e;
			break;
		case 'i':
			temp = HELP_i;
			break;
		case 'f':
             if (cmd_chr2 == 'i')
                {
                temp=HELP_fi;
                count = ReadInputFile(START_USER_DATA, Data);
                }
                else if (cmd_chr2 == 'o')
                     temp=HELP_fo;
                     else temp=NO_COMMAND;
             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':
             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;
             if (IsDigit(cmd_chr2))
                ;
             break;
        case 'm':
             temp = HELP_m;
             break;
        case 's':
             cout << HELP_s;
             cout << HELP_sd;
             temp="";
             break;
        case 'p':
             temp = HELP_p;
             break;
        case 'M':
             if (cmd_chr2 == '1')
                temp=HELP_M1;
                else if (cmd_chr2 == '2')
                     temp=HELP_M2;
                     else temp=NO_COMMAND;
             break;
        case 'N':
              if (cmd_chr2 == '1')
                temp=HELP_N1;
                else if (cmd_chr2 == '2')
                     temp=HELP_N2;
                     else temp=NO_COMMAND;
             break;
		default:
			temp = "NO_COMMAND \n";
	}		
	cout << temp;
	
	// Clear current line out (if needed)
	
	if (cmd_chr2 != '\n')
	   cin.ignore(100, '\n');
	}
}

void help_function()
{
cout <<  HELP_e;
cout <<  HELP_i;
cout <<  HELP_fi;
cout <<  HELP_fo;
cout <<  HELP_plus;
cout <<  HELP_minus;
cout <<  HELP_star;
cout <<  HELP_slash;
cout <<  HELP_caret;
cout <<  HELP_exclaim;
cout <<  HELP_c;
cout <<  HELP_cL;
cout <<  HELP_h;
cout <<  HELP_l;
cout <<  HELP_q;
cout <<  HELP_o;
cout <<  HELP_a;
cout <<  HELP_d;
cout <<  HELP_m;
cout <<  HELP_s;
cout <<  HELP_sd;
cout <<  HELP_p;
cout <<  HELP_M1;
cout <<  HELP_M2;
cout <<  HELP_N1;
cout <<  HELP_N2;
return;
}

bool IsDigit(char chr2)
{
// Tests whether or not the char chr2 is a digit
bool flag = true;
if ( (int) chr2 < 48 || (int) chr2 >57 )
   flag = false;
return flag;     
}

int ReadInputFile(index, List)
{
}

