Please send questions to st10@humboldt.edu .
/*
  Contract: request_changes: double[] int -> void
  Purpose: interactively ask user to enter index of
           value in the array of <size> values <values>
           and then the new value to be placed at that index,
           then changing that value of <values> accordingly,
           until the user enters an index of -1.
  Examples: for const int NUM_VALUES = 5; and
                double stuff[NUM_VALUES] = {1.1, 1.2, 1.3, 1.4, 1.5};
            if the user ran request_changes(stuff, NUM_VALUES)
                and when prompted enters 1, 27, 3, 54, -1,
                then afterwards stuff will == {1.1, 27, 1.3, 54, 1.5}
                (although you can't directly make that comparison...)
*/

#include <iostream>
#include "request_changes.h"
using namespace std;

void request_changes(double values[], int size)
{
    int next_index;
    double new_value;

    cout << "Enter index of value to be changed (or " 
         << ENDING_INDEX << " to quit): ";
    cin >> next_index;

    while (next_index != ENDING_INDEX)
    {
        // what if user gives an inappropriate index?

        if ((next_index < 0) || (next_index >= size))
        {
            cout << "Index must be between 0 and " << (size-1) << endl;
        }

        // if reach here, index IS in appropriate range

        else
        {
            cout << "new value for index " << next_index << ": ";
            cin >> new_value;
            values[next_index] = new_value;
        }

        cout << "Enter index of value to be changed (or "
             << ENDING_INDEX << " to quit): ";
        cin >> next_index;
    }
}