This is a bit of homework I have to do for my C++ class. I was suppose to add 11 as the pay code and 23 as the pay rate, but during the debug test when I type in 11 it doesn't display $23 like it's suppose to. What am I doing wrong here?
//Purpose: Displays the pay rate corresponding to the pay code entered by the user
//Input: The pay code
//Output: The pay rate
#include <iostream>
using namespace std;
int main()
{
//declare array and variables
int codesAndRates[5][2] = {{3, 8}, {7, 10}, {6, 14}, {9, 20}, {11, 23}};
int payCode = 0;
int rowSubscript = 0;
//get pay code
cout << "Pay code (3, 7, 6, 9, or 11). " << endl;
cout << "Enter a negative number to end: ";
cin >> payCode;
while (payCode >= 0)
{
//search each row in the array, looking for the pay code in the first column
//continue the search while there are array elements to search and the pay code has not been found
rowSubscript = 0;
while (rowSubscript <= 3 && codesAndRates[rowSubscript][0]!= payCode)
rowSubscript += 1;
//end while
//if the pay code was found, display the pay rate located in the same row but in the second column in the array
if (rowSubscript <= 3)
cout << "Pay rate for pay code " << codesAndRates[rowSubscript][0] << ": $" << codesAndRates[rowSubscript][1] << endl;
//end if
//get pay code
cout << "Pay code (3, 7, 6, 9, or 11). " << endl;
cout << "Enter a negative number to end: ";
cin >> payCode;
} //end while
system("pause");
return 0;
} //end of main function