title: C++ Problems inputting value into class objects
body: <p>I am taking a class on C++ currently and need help with a certain part of my code. It all compiles but when I go to test it I am only allowed to input one value into the window before the rest of the code advances through without input. </p>
  
  <p>For reference, this is the question I am answering:
  11. Payroll</p>
  
  <p>Design a PayRoll class  that has data members for an employee’s hourly pay rate, number of hours worked of type  double . The default constructor  will set the hours worked and pay rate to zero. The class  must have a mutator function to set the pay rate for each employee and hours worked. The class  should include accessors for both the hours worked and the rate of pay. The class  should lastly have a getGross function that will return a double  calculated by multiplying the hours worked by the rate
  of pay.</p>
  
  <p>Write a program  with an array  of seven PayRoll objects . The program  should ask the user for the rate of pay for each employee and the number of hours each employee has worked. Be sure to include an employee claiming to work more then 60 hours per week. Print out, the array  number of the employee, the hours worked, the rate of pay, and the gross pay, of all the employee's each on their own line. Set the precision for printing the doubles  to two decimal places.</p>
  
  <p>Input Validation: Do not accept values  greater than  60 for the number of hours worked, simply have the set function set number of hours worked to 60, the maximum allowed.</p>
  
  <p>My code is as follows: </p>
  
  <pre><code>#include &lt;iostream&gt;
  #include &lt;iomanip&gt;
  
  //Garrett Bartholomay
  /*This program defines and implements the Payroll class.
   * The class is then used in a program that calculates gross pay for an array of
   * Payroll objects after accepting values for hours and pay rate from standard input*/
  
  class Payroll
  {
  private:
      int hoursWorked;
      double payRate;
  public:
      Payroll();
      Payroll(int, double);
      void setHours(int);
      void setPayRate(double);
      int getHours() const;
      double getPayRate() const;
      double getGross()const;
  };
  Payroll::Payroll()
  {
      hoursWorked = 0;
      payRate = 0.0;
  }
  Payroll::Payroll(int h, double r)
  {
      payRate = r;
      hoursWorked = h;
  }
  void Payroll::setHours(int h)
  {
      hoursWorked = h;
  }
  void Payroll::setPayRate(double p)
  {
      payRate = p;
  }
  int Payroll::getHours() const
  {
      return hoursWorked;
  }
  double Payroll::getPayRate() const
  {
      return payRate;
  }
  double Payroll::getGross() const
  {
      double gross = static_cast&lt;double&gt;(hoursWorked) * payRate;
      return gross;
  }
  
  using namespace std;
  int main()
  {
  
      const int NUM_EMPLOYEES = 7;
      Payroll employee[NUM_EMPLOYEES];
      int pay;
      int hours;
      int i;
      double grossPay;
  
      for (i = 0; i &lt; NUM_EMPLOYEES; i++)
      {
  
          cout &lt;&lt; "Enter the # " &lt;&lt; (i) &lt;&lt; " employee's rate of pay per hour: ";
          cin &gt;&gt; pay;
          cout &lt;&lt; "Enter the # " &lt;&lt; (i) &lt;&lt; " employee's hours worked for the week: ";
          cin &gt;&gt; hours;
  
          employee[i].setPayRate(pay);
          employee[i].setHours(hours);        
      }
      cout &lt;&lt; "\n\nHere is the gross pay for each employee:\n";
      cout &lt;&lt; fixed &lt;&lt; showpoint &lt;&lt; setprecision(2);
      for (int i = 0; i &lt; NUM_EMPLOYEES; i++)
      {
          grossPay = employee[i].getGross();
          cout &lt;&lt; "The gross pay for employee # " &lt;&lt; (i) &lt;&lt; " is: " &lt;&lt; grossPay &lt;&lt; endl;      
      }
      return 0;
  }
  </code></pre>
  
  <p>The input resides within the loops. </p>
  
  <p>Any help would be greatly appreciated. </p>
  
  <p>Thanks, </p>
  
  <p>G</p>