// Name:  Micheal H. McCabe
// April 1, 2009
// Exam #2 Source Code -- Revised for proper rounding
//
//
// Includes and namespace definitions

#include <iostream>
#include <iomanip>
#include <cmath>
using namespace std;

// Function Prototypes

double Addemup(double Data[]);
int AddInt(double Data[]);
void listem(double Data[]);
double roundhalf(double num);

// Main Routine

int main()
{
	double Data [ ] = {8, 50.5, 60.6, 70.7, -25.5, -30.3, -35.3, 10, 20, 0, 0, 0};
	double sum;
	int total;
	char c1  = '\0';

	while ( c1 != 'q' )
		{
		cout << "Choose Letter: t, s, q, l:";
		cin >> c1;

		switch (c1)
			{
				case 't':
					{
					sum=Addemup(Data);
					break;
					}
				case 's':
					{		
					total=AddInt(Data);
					break;
					}
				case 'l':
					{	
					listem(Data);
					break;
					}
				case 'q':
					{
					// Since the while loop depends on the value of c1
					// anyway, we really don't need to do anything here.
					break;
					}
				default:
					{
					cout << "Not accepted\n";
					break;
					}
			}
		}
		cout << fixed << setw(10) << setprecision(2) << showpoint
     		<< "Dbl Sum=" << sum << setprecision(0) << "; Int Total="
	 	<< total << "; All Done!\n";
	return 0;
}

double Addemup(double Data[])
{
	double total=0;
	int i;
	for (i=0; i<=(int)Data[0]; i++)
		total=total+Data[i];
	return total;
}

int AddInt(double Data[])
{
	int total=0;
	int i;
	float rounded;
	for (i=1; i<=(int)Data[0]; i++)
		{
		total=total+round(Data[i]);
		cout << Data[i] << " = Rounded = " << round(Data[i]) << endl;
		}
	return total;
}

void listem(double Data[])
{	
	int i;
	for (i=1; i<=(int)Data[0]; i++)
		{
		cout << "Element: " << i << " Data: " << Data[i] << endl;
		}
	return;
}


