/* 
 * Implementation file for exam2. This is the file you will actually be working
 * on. This is the ONLY file you will be turning in. Do not make any changes to
 * the function headers!
 * 
 * Please see the header file for explanations on what the functions should do.
 * Run this file together with the main file to see if your implementations are
 * correct.
 * 
 * Remember: NONE of your functions should have any screen input/output (do not
 * use cin / cout). Instead, use the parameters given to get your input and
 * return your output!
 */

/*
 * Your Name:
 */

#include <string>
#include <cstring>
#include <cmath>
#include "exam2impl.h"
using namespace std;

 
char numberToLetterGrade(int grade)
{
	char letterGrade = 'F';
	if (grade>=90) letterGrade='A';
	else if (grade>=80) letterGrade='B';
	else if (grade>=70) letterGrade='C';
	return letterGrade;
}
 
void UpPeRlOwEr (char c[]) 
{
	int i;
	for (i=0;c[i];i++) 
    	if (i%2==0)
    		c[i] = toupper(c[i]);
    	else
    		c[i] = tolower(c[i]);
}
 
string UpPeRlOwEr (string s)
{
	int i;
	for (i=0;i<s.length();i++) 
    	if (i%2==0)
    		s[i] = toupper(s[i]);
    	else
    		s[i] = tolower(s[i]);
	return s;
}
 
int elementForIndex(int *a, int index)
{
	return a[index];
}
 
int coordinateForIndex(coordinate *c, int index)
{
	switch (index) {
		case 1: return c->x;
		case 2: return c->y;
		case 3: return c->z;
	}
	return 0;
}

int *allocateDynamicArrayAndFillWithNumbers(int count)
{
  int *a = new int[count];
  int i;
  for (i=0;i<count;i++) a[i] = i+1;
  return a;
}
