// Example programming exam
// In the exam you will be given a program that already has some
// functions, but they have no functionality. It is up to you to
// actually implement them.

// Please put your name in the next line:
// Your Name: Max Berger


#include <iostream>
using namespace std;

void helloWorld()
// This function will print "Hello, World!". Formatting does not matter
{
  cout << "Hello, World!" << endl;
}

void helloFancy()
/* This function will print 
Hello
 World
  Nice
   To
    Be
     Here
In 6 lines with the formatting as shown. Don't forget the newline after "Here!"
*/
{
  cout << "Hello" << endl;
  cout << " World" << endl;
  cout << "  Nice" << endl;
  cout << "   To" << endl;
  cout << "    Be" << endl;
  cout << "     Here" << endl;
}

void oldEnoughToDrink(int age)
// This function will print "Yes, you are old enough" if the 
// age passed in is at least 21, or "Sorry, too young" if not
// Use only One IF-Statement 
{
  if (age >= 21)
    cout << "Yes, go ahead" << endl;
  else 
    cout << "Nope, sorry!" << endl;
}

void bouncer(int age)
// This function will print "Armband" if the 
// age passed in is at least 21, "Black X" if the age is betwen 18 and 20
// (inclusive) or "Can't come in" if the age is below 18. 
// use a chain of if / else if / else 
{
  if (age >= 21) 
    cout << "Armband";
  else if (age >= 18) 
    cout << "Black X";
  else 
    cout << "Can\'t come int";
  cout << endl;
}


enum whatToDo { study, movie, bar, pool };

whatToDo enterWhatToDo()
// This function will give the user the above choices for evening entertainment
// It will then read in a "char", and somehow convert that to an "whatToDo" 
// type. (hint: static_cast will not work here)
{
  char c;
  whatToDo retval;
  cout << "What do you want to do? (S)tudy, (M)ovie, (B)ar, (P)ool ? ";
  cin >> c;
  c = tolower(c);
  switch (c) {
    case 's': retval =  study; break;
    case 'm': retval =  movie; break;
    case 'b': retval =  bar; break;
    case 'p': retval =  pool; break;
    default: 
      cout << "I didn't give you that option. Study some more!" << endl;
      retval = study;
  } 
  return retval;
}

void bananas(int howmany)
// This function will print on screen:
// 1 banana
// 2 banana
// 3 banana
// ...
// from 1 to and inclusive the passed in "howmany"
{ 
  int i;
  for (i = 1; i <= howmany; i++)
    cout << i << " banana" << endl;
}

void loopinLoop(int width, int height)
// This function will print a solid box of stars (*) with the width and height
// given in the parameters
{
  int x,y;
  for (y=0;y<height;y++) {
    for (x=0;x<width;x++) cout << "*";
    cout << endl;
  }
}

float squareByValue(float ofWhat)
// This function will return the square of ofWhat
{
  return ofWhat*ofWhat;
}

void squareByReference(float &ofWhat)
// This function will modify ofwhat to contain the square of ofWhat
{
  ofWhat = ofWhat*ofWhat;
}

void printArray(const int a[], int size)
// Prints the values of the given array a with size size on screen
// seperate them by either a space or newline!
{
  int i;
  for (i=0;i<size;i++) cout << a[i] << endl;
}

void clearArray(int a[], int size, int withWhat=0)
// uses a loop to reset all the elements from index 0 to size-1 to 
{
  int i=0;
  for (i=0;i<size;i++) a[i] = withWhat;
}

void doubleElementsOfArray(int a[], int size)
// doubles every element in the given array.
// e.g: a[0] = 5 before, then a[0] = 10 afterwards
{
  int i;
  for (i=0;i<size;i++) 
    a[i] = a[i]*2;
}


float average(int a[], int size)
// Returns the average for all elements in the array. 
// Warning: You MUST use floating point division!
{
  float sum = 0; 
  int i;
  for (i=0;i<size;i++) sum+=a[i];
  return sum/size;
}

void print2D(char matrix[][40], int cols, int rows)
// Prints the characters from the two dimesional array matrix
// on screen. The first index is used for the columns, the second one
// for the rows. There are cols columns and rows rows used inside the 
// array 
{
  int x,y;
  for (y=0;y<rows;y++) {
    for (x=0;x<cols;x++) cout << matrix[x][y];
    cout << endl;
  }
}

int main()
{}
