employee payroll program

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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//payroll program
//created by Jett Bailes

#include <iostream>
#include <string>
#include <iomanip>


using std::endl;
using std::cout;
using std::cin;
using std::string;
using std::fixed;
using std::setprecision;

double calcFWT(double, double, double);
double calcFICA(double, double, double);
double calcNetPay(double, double, double, double);
void getInput(string &, double &);
void displayInfo(string, double, double, double);

int main()
{
	string name = "";
	double weeklySalary = 0.0;
	double FWTrate = .2;
	double FWT = 0.0;
	double FICArate = .08;
	double FICA = 0.0;
	double weeklyNetPay = 0.0;

	cout << fixed << setprecision(2);
	getInput(name, weeklySalary);
	FWT = calcFWT(weeklySalary, FWTrate, FWT);
	FICA = calcFICA(weeklySalary, FICArate, FICA);
	calcNetPay(weeklySalary, FICA, FWT, weeklyNetPay);
	displayInfo(name, FWT, FICA, weeklyNetPay);

return 0;
}

//////////////////////////////////////////
double calcFWT(double weeklySalary, double FWTrate, double FWT)
{
	FWT = weeklySalary / FWTrate;
	return FWT;
}

double calcFICA(double weeklySalary, double FICArate, double FICA)
{
	FICA = weeklySalary / FICArate;
	return FICA;
}

double calcNetpay(double weeklySalary, double FICA, double FWT, double weeklyNetPay)
{
	weeklyNetPay = weeklySalary - (FICA + FWT);
	return weeklyNetPay;
}
////////////////////////////////////

void getInput(string &employeeName, double &salary)
{
	cout << "Enter name: ";
	getline (cin, employeeName);
	cout << "Enter weekly salary: ";
	cin >> salary;
}

void displayInfo (string employeeName, double FWT, double FICA, double weeklyNetPay)
{
	cout << "Name: " << employeeName << endl;
	cout << "FWT: " << FWT << endl;
	cout << "FICA: " << FICA << endl;
	cout << "Weekly Net Pay: " << weeklyNetPay << endl;
}






I get these errors:
1>Ch10AppE07.obj : error LNK2019: unresolved external symbol "double __cdecl calcNetPay(double,double,double,double)" (?calcNetPay@@YANNNNN@Z) referenced in function _main

1>C:\Users\Bailes\Desktop\SCHOOL\COSC230 Intro to C++ Programming\83618-4\Cpp5\Chap10\Chap10AppE07\Debug\Chap10AppE07.exe : fatal error LNK1120: 1 unresolved externals
You have a typo in your function name calcNetpay
Ok I see, thanks. The calculations aren't correct though. I changed the calculations from diving the rates by the weekly pay to multiplying them (duh). My question is this:

How can I code the sum of the product of (weekly pay * FWT) and (weekly pay * FICA) and subtract it from the beginning weekly pay in a the function calcNetPay?
Ok check out my calcNetPay function. I figured this would work, any ideas as to what i'm doing 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
//payroll program
//created by Jett Bailes

#include <iostream>
#include <string>
#include <iomanip>


using std::endl;
using std::cout;
using std::cin;
using std::string;
using std::fixed;
using std::setprecision;

double calcFWT(double, double, double);
double calcFICA(double, double, double);
double calcNetPay(double, double, double, double);
void getInput(string &, double &);
void displayInfo(string, double, double, double);

int main()
{
	string name = "";
	double weeklySalary = 0.0;
	double FWTrate = .2;
	double FWT = 0.0;
	double FICArate = .08;
	double FICA = 0.0;
	double weeklyNetPay = 0.0;
	
	cout << fixed << setprecision(2);
	getInput(name, weeklySalary);
	cout << endl;
	FWT = calcFWT(weeklySalary, FWTrate, FWT);
	FICA = calcFICA(weeklySalary, FICArate, FICA);
	calcNetPay(weeklySalary, FICA, FWT, weeklyNetPay);
	displayInfo(name, FWT, FICA, weeklyNetPay);

return 0;
}

//////////////////////////////////////////
double calcFWT(double weeklySalary, double FWTrate, double FWT)
{
	FWT = weeklySalary * FWTrate;
	return FWT;
}

double calcFICA(double weeklySalary, double FICArate, double FICA)
{
	FICA = weeklySalary * FICArate;
	return FICA;
}

double calcNetPay(double weeklySalary, double FICA, double FWT, double weeklyNetPay)
{
	double sum = FICA + FWT;

	weeklyNetPay = weeklySalary - sum;

	return weeklyNetPay;
}
////////////////////////////////////

void getInput(string &employeeName, double &salary)
{
	cout << "Enter name: ";
	getline (cin, employeeName);
	cout << "Enter weekly salary: ";
	cin >> salary;
}

void displayInfo (string employeeName, double FWT, double FICA, double weeklyNetPay)
{
	cout << "Name: " << employeeName << endl;
	cout << "FWT: " << FWT << endl;
	cout << "FICA: " << FICA << endl;
	cout << "Weekly Net Pay: " << weeklyNetPay << endl;
}


You look like you already know how...you would just need to get the values into and so this.

(beginning weekly pay) - (weekly pay * FWT) + (weekly pay * FICA)

If that's not what you're meaning, I don't know.
Ok before I start changing and adding any more variables. How would you go about differentiating beginning weekly pay and weekly pay without getting confusion within the function?
I'm not sure I understand. How would the function get confused between two variables, likely with different values?
Ok so weeklyPay is entered by the user in the getInput function. should i make beginningWeeklyPay be the variable entered by the user instead? How will the program know that when the user enters a value for beginningWeeklyPay it is the same for weeklyPay?

I'm having a hard time communicating what I mean here...
Topic archived. No new replies allowed.