Confused on Homework problem

This is what are assignment consist of:

J Inc. has 2 employees. You are asked to write a C++ program calculate the salary for each employee. From the
keyboard, read a person’s first name, last name, id, wage, the number of hours worked in a week, and his or her
status. For the output, you must display all the inputs, straight time pay, overtime pay, employee status and net
pay. For full-time employees, $10 is deducted from wages for union fees. A person is full-time if the status is F.
Time and a half is paid for any time worked over 40 hours in a week. Make sure the output is formatted into rows
and columns and includes the appropriate titles and column headings, and it should like a Pay Check.


This is what I have so far:

#include <iostream>
#include <string>
using namespace std;

int main (void)
{
int employeeID, hrsWorked,hourlyWage, totalPay, finalPay;
int fullTimeHours (40);
//int overPay ();
//int deduction (10);


char fullTime = 'F';
char part_Time = 'P';

//user inputs
string firstName ("");
cout << "Please enter employee's first name :\t" << endl;
cin >> firstName;

string LastName ("");
cout << "Please enter employee's last name :\t" << endl;
cin >> LastName;

cout << "Please enter employee's identification :\t" << endl;
cin >> employeeID;

cout << "Please enter employee's hourly wage :\t" << endl;
cin >> hourlyWage;

cout << "Please enter employee's total hours of work :\t" << endl;
cin >> hrsWorked ;

string jobStatus ("");
cout << "Please enter employee's status" << endl;
cin >> jobStatus;

//hourly calculations
if(hrsWorked > fullTimeHours)
{
hrsWorked * hourlyWage * overPay = totalPay;
}

else (hrsWorked <= fullTimeHours)
{
hrsWorked * hourlyWage = finalPay;
{
if (jobStatus == F)

totalPay - deduction = finalPay;
else
(jobStatus == P)
cout << "Job Status: Part - Time\t" << P <<endl;
}

return 0;
}

I tested all my inputs and they are working correctly. I don't have output statements yet but don't worry about those. I am worried about the if statement. I tried to nest and I am wondering if I am doing it correctly. Secondly am I using the char correctly in the if statement? Does the set up calculation look correct? Please see problem above.
about char.
if (jobStatus=="F")...
if(jobStatus=="P")... //that's right

and to my mind if(...){..}else if(...){} than if(...){..}else(...){} (is clearer)

and string (hrsWorked * hourlyWage = finalPay;) is wrong; you should write finalPay=hrsWorked * hourlyWage;

if I am wrong correct my answers.
closed account (3hM2Nwbp)
I haven't paid attention to the logic details, but have merely fixed some syntax for you. Please wrap your code in [ code ] tags in the future, thanks.

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
int main (void)
{
	int employeeID, hrsWorked,hourlyWage, totalPay, finalPay;
	int fullTimeHours (40);
	int overPay; /*EDIT - Remove ()*/
	int deduction (10);


	char fullTime = 'F';
	char part_Time = 'P';

	//user inputs
	string firstName ("");
	cout << "Please enter employee's first name :\t" << endl;
	cin >> firstName;

	string LastName ("");
	cout << "Please enter employee's last name :\t" << endl;
	cin >> LastName;

	cout << "Please enter employee's identification :\t" << endl;
	cin >> employeeID;

	cout << "Please enter employee's hourly wage :\t" << endl;
	cin >> hourlyWage;
	/*EDIT*/
	overPay = hourlyWage * 1.5; //Time and a half

	cout << "Please enter employee's total hours of work :\t" << endl;
	cin >> hrsWorked ;

	string jobStatus ("");
	cout << "Please enter employee's status" << endl;
	cin >> jobStatus;

	//hourly calculations
	if(hrsWorked > fullTimeHours)
	{
		/*EDIT*/
		//Variable = calculation, not calculation = variable
		totalPay = hrsWorked * hourlyWage * overPay;
	}
	/*EDIT - else if(expression), not else(expression)*/
	else if(hrsWorked <= fullTimeHours)
	{
		/*EDIT*/
		//Variable = calculation
		finalPay = hrsWorked * hourlyWage;
	{
	if (jobStatus == "F")
		/*EDIT*/
		//Variable = calculation
		finalPay = totalPay - deduction;
	/*EDIT - else if*/
	else if(jobStatus == "P")
		cout << "Job Status: Part - Time\t" << "P" <<endl;
	}

	return 0;
}


Let me know if you have any more questions.

Best regards,
Luc
Topic archived. No new replies allowed.