repeating program with functions

Hi! This program is meant to calculate the gross pay with the use of various functions. I need the program to repeat itself until the name entered is 'NULL' and be able to track the total number of employees processed, total regular hours, and total overtime. For now I just need help on repeating my program, so I can start working on the tracking part. (I inserted a do while loop in the main, but its surely wrong)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#include <iostream>
#include <string>
#include <iomanip>
#include <cstdlib>

using namespace std;

void introduction ()
{
	cout<< "Please enter the information required and I will calculate for you your Gross Pay. " ;
	
}



void getInput (string & name, double & hourly, double & totalHours)
{ cout<< "Please enter your name:" ;
cin>> name;
cout<< "What is your hourly wage? " ;
cin>> hourly;
cout << "How many hours did you work in total?" ;
cin>> totalHours;
}

double computeWage (double hourly, double totalHours)
{double grossPay;

if (totalHours > 40)
{grossPay = (hourly*40)+(totalHours-40)*hourly; }
else if (totalHours <= 40)
{grossPay = totalHours * hourly; }
return grossPay;
}

void displayEmpData (string name, double totalHours, double hourly, double grossPay)
{ cout<<endl;
	cout<< "Employee Name	" << " Total Hours	" << "Hourly wage	 " << "Gross pay	" ;
cout<<endl;

  cout<< name << "		" << totalHours<< "		" << hourly << "		" << grossPay;
}

int main()
{
	string name;
	double totalHours, hourly, grossPay;


	introduction;
	getInput (name, hourly, totalHours);
	do {
	grossPay = computeWage(hourly, totalHours);
	displayEmpData(name, totalHours, hourly, grossPay);}
	while (name =! NULL);

	system ("pause");
	return 0;
}
Last edited on
(name =! NULL) should be (name =! "NULL")
NULL without quotes is not a string.
hi yay295, thanks for the help. Im getting an error though under name. It says 'expressions must have bool type (or be convertible to bool). Im not sure what to do to get rid of the error.
Oh, lol, I didn't know this was an error. Change =! to !=. Apparently the order makes a difference.

Also, you didn't actually call 'introduction' at line 49. You have to put the parentheses there.
Thank you so much Yay295!! my program is working now! :)
Topic archived. No new replies allowed.