I put a string in to the following program so that I could output the full employees name. After input it works perfectly but if i continue the loop with 1 ad type in the next employees name it goes into an infinite loop. Before I added the get line string it didnt do this but would display the full name.
#include<iostream>
#include<string>
using namespace std;
int main()
{
const double regularHours=40; //Stores 40 into regular hours determines whether hours are overtime or not
int employee_count, another_employee; //First stores number of employees, second allows for 1 or 0 to decide if you want to keep running the program
string employeeName;
double hoursWorked, payRate, regularPay, OTPay, grossPay,
netPay; // Used to store all employee info and calculate pay
double totalGrossPay = 0;
double totalNetPay = 0;
double averageNetPay = 0;
double averageGrossPay=0;
employee_count=0;
//Variables above store all total values before program is run and eventually
//is used to calculate overall totals
cout<<"***Welcome to your Employee Paystub Generator!***"<<endl;
do
{
cout <<endl;
cout <<"Please enter your employee's first and last name: ";
getline(cin,employeeName);
cout <<endl;
cout <<"Number of hours worked this week? : ";
cin>> hoursWorked;
cout<<endl;
cout<<"Employee's Payrate? : ";
cin>>payRate;
employee_count++;
cout<< "\nThe total gross pay for your employees is: " << totalGrossPay;
cout<<endl;
cout<<"The total net pay for your employees is: " << totalNetPay;
cout<<endl;
cout<<"The average gross pay for your employees is: " << averageGrossPay;
cout<<endl;
cout<<"The average net pay for your employees is: " << averageNetPay<<endl;
cout<<endl;
Please edit your post using the code tags and with proper indentation, it makes it much easier for us to read and understand your code and you will get more replies.