Help with this program.

Hello I've been having to work and rework this program for weeks. I am wondering if someone cn look at and help.It will be appreciated. Here is the assignmentment info.

PART B: Rewrite Lab 4 (Pay Calculation Program)
Add these functions:

Function Name: display( )
Arguments: None
Return Value: None
Prototype: void display(void);
Action: Display name and lab number
Function Name: code_not_valid( )
Arguments: pay code (a char)
Return Value: true, if bad code; false, if good code
Prototype: bool code_not_valid(char);
Action: Use do/while loop in main to enter pay code
Test T/F value returned by function to see if another iteration is necessary
Function Name: get_pay( )
Arguments: pay code and hours (pass by value) and pay rate (pass by reference)
Return Value: pay
Prototype: double get_pay(char, double, double &)
Action: Determine pay rate and calculate pay. (Both decision constructs are in this function)

Program Interaction:

These are the inputs and the expected outputs.
Anywhere you see ???? requires your program to output some value.
Assignment 5A Programmed by yourname here
Enter Employee #, Pay Code, Hours:
1032864 M 41
Pay Rate: $??.?? Pay Amount: $???.??
Another employee to process (Y/N)? y
Enter Employee #, Pay Code, Hours:
1171955 T 38
Pay Rate: $??.?? Pay Amount: $???.??
Another employee to process (Y/N)? y
Enter Employee #, Pay Code, Hours:
1224096 O 45
Pay Rate: $??.?? Pay Amount: $???.??
Another employee to process (Y/N)? y
Enter Employee #, Pay Code, Hours:
1234567 N 40
INVALID PAY CODE
Pay Rate: $??.?? Pay Amount: $???.??
Another employee to process (Y/N)? n
Number of Employees Processed: ?? Total Payroll: $????.??

Normal Job Termination

and here is the code:


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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
  //Project Name: Lab Assignment 5a:   Using Decisions for Pay Calculations
//Programer name: Rodger Coleman
// Date written: 2/8/2022
//Description: Calculate Payroll uaing functions
#include <iostream> //Header File for console I/O
#include <iomanip>


using namespace std;

//function prototypes
void display();
bool code_not_valid(char);
double get_pay(char, double, double &);

const double MIN_WAGE = 15;
const double NORM_HOURS = 40;
// begin main Function Definition
int main()
{
	int value;
// declarations	
	display();
	string employeeID;
	double hoursWorked = 0, totalPay = 0, payRate = 0;
	char payCode, again;
	
	do
{
// type in employee id, pay code and hoursworked
	cout << "Enter Employee #, Pay Code, Hours:" << endl;
	cin >> employeeID >> payCode >> hoursWorked;
	
// useing switch allows user to put in paycodes
	switch (payCode){
	case 'm':
	case 'M': payRate = MIN_WAGE;
			break;
				
	case 'o':	case 'O': payRate = MIN_WAGE + 1.00;
			break;
	case 't':
	case 'T': payRate = MIN_WAGE + 2.00;
			break;
	case 'n':
	case 'N': 
	default: cout << "you have entered the incorrect paycode" <<  endl;	
	break;
	
}
// calculate minimum hours worked and overtimee.	
	if (payRate) {
		double totalPay (hoursWorked * payRate);
	if (hoursWorked > NORM_HOURS)
		totalPay += payRate * (hoursWorked - NORM_HOURS) * 1.5;
		cout << setprecision(2) << fixed;
		cout << "Pay rate: $ " << setw(2) << payRate << " Pay Amount: $ " << setw(2) << totalPay << '\n';
	
}
	
		
		cout << "add another employee? (Y/N): ";
		cin >> again;					
} while ( again == 'Y' || again == 'y');

return 0;
	
}
*************************************************************
* //Arguments:  None
* //Return Value:  None
* //Prototype:  void display(void);
* //Action:  Display name and lab number                                                                                                                                                                                                                                           
*************************************************************	

void display()
{
	cout << "Assignment 5b"  << endl;
	cout << "Programmed by Paul Duckworth" << endl;
}

*********************************************************************************
* //Arguments:  pay code (a char)
* //Return Value:  true, if bad code; false, if good code
* //Prototype:  bool code_not_valid(char);
* //Action:  Use do/while loop in main to enter pay code
* //Test T/F value returned by function to see if another iteration is necessary                                                                                                                   
*********************************************************************************


	bool code_not_valid(char pay_code )
{
	bool status;
	if ()
		status = true;
		else
		status = false;
	return status;
}

*************************************************************************************
* // Arguments: pay code and hours (pass by value) and pay rate (pass by reference) 
* //Return Value:  pay Prototype:  double get_pay(char, double, double &)
* //Action:  Determine pay rate and calculate pay.                                                           
* //(Both decision constructs are in this function)                                                                                                                      *
*************************************************************************************
 get_pay()
{
	totalPay += payRate * (hoursWorked - NORM_HOURS) * 1.5;
	return paycode + hours;
}
//end of main function.

What are you expecting the program to do, and what is it actually doing? Or not doing?
I copy'n'paste your code into Visual Studio and I get a nice list of errors. What look to be C style multi-line comments that are not is one of the biggie mistakes. Lines 69-74, lines 82-88 and lines 101-106.

FYI, C style multi-line comments begin with /* and end with */.

line 94, what is the test condition of the if statement? Can't be blank.

Your function starting at line 107, what is the return type? double by the function declaration at line14. A declaration that expects to pass a char, a double and a reference to a double. Your definition doesn't match the declaration.

Your get_pay() function, the variables are undefined. Defining them in main doesn't magically mean they are usable in other functions, unless you pass them as parameters to the function.
Passing paycode, hours and payRate (as specified by the comment) still leaves totalPay and hoursWorked as undefined.
its the same program i worked on before but supposed to to be rewritten with functions basically.
so void for the title part(not a problem)so im not worried about that

Boolean for t/f for value returned. if pay code is wrong false if not wrong true.

pay code and hours to (pass by value) and the pay rate passed by reference. To determine pay rate and calclulate pay.

I have been stuck on this program for a while , so im wondering what another person can do with and see what im missing.

this is the output it is supposed to have if it helps:

Anywhere you see ???? requires your program to output some value.
Assignment 5A Programmed by yourname here
Enter Employee #, Pay Code, Hours:
1032864 M 41
Pay Rate: $??.?? Pay Amount: $???.??
Another employee to process (Y/N)? y
Enter Employee #, Pay Code, Hours:
1171955 T 38
Pay Rate: $??.?? Pay Amount: $???.??
Another employee to process (Y/N)? y
Enter Employee #, Pay Code, Hours:
1224096 O 45
Pay Rate: $??.?? Pay Amount: $???.??
Another employee to process (Y/N)? y
Enter Employee #, Pay Code, Hours:
1234567 N 40
INVALID PAY CODE
Pay Rate: $??.?? Pay Amount: $???.??
Another employee to process (Y/N)? n
Number of Employees Processed: ?? Total Payroll: $????.??

Normal Job Termination




its the same program i worked on before


Please don't start a new topic for the same subject, ultimately it's a time waster for those who reply, just continue with the old one.
@OP
I assume you are the Mr Duckworth. Have you got the go ahead from Mr Coleman to use his work? You can use mine if you like but I suggest you check it thoroughly if you do.

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
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
//Project Name: Lab Assignment 5a:   Using Decisions for Pay Calculations
//Programer name: Rodger Coleman
// Date written: 2/8/2022
//Description: Calculate Payroll uaing functions
#include <iostream> //Header File for console I/O
#include <iomanip>


using namespace std;

//function prototypes
void display();
bool code_not_valid(char);
double get_pay(char, double, double &);

const double MIN_WAGE = 15;
const double NORM_HOURS = 40;
// begin main Function Definition
int main()
{
    int value;
    // declarations
    display();
    string employeeID;
    double hoursWorked = 0, totalPay = 0, payRate = 0;
    char payCode, again;
    
    do
    {
        // type in employee id, pay code and hoursworked
        cout << "Enter Employee #, Pay Code, Hours:" << endl;
        cin >> employeeID >> payCode >> hoursWorked;
        
        // useing switch allows user to put in paycodes
        switch (payCode){
            case 'm':
            case 'M': payRate = MIN_WAGE;
                break;
                
            case 'o':    case 'O': payRate = MIN_WAGE + 1.00;
                break;
            case 't':
            case 'T': payRate = MIN_WAGE + 2.00;
                break;
            case 'n':
            case 'N':
            default:
                cout << "you have entered the incorrect paycode" <<  endl;
                payCode = '*';
                break;
        }
        
        // calculate minimum hours worked and overtimee.
        if (code_not_valid(payCode) == true)
        {
            cout
            << setprecision(2) << fixed << "Pay rate: $ " << setw(2) << payRate
            << " Pay Amount: $ " << setw(2)
            << get_pay(payCode, hoursWorked,payRate) << '\n';
        }
        
        
        cout << "add another employee? (Y/N): ";
        cin >> again;
    } while ( again == 'Y' || again == 'y');
    
    return 0;
    
}

void display()
{
    cout << "Assignment 5b"  << endl;
    cout << "Programmed by Paul Duckworth" << endl;
}

bool code_not_valid(char pay_code )
{
    bool status;
    if (pay_code == '*')
    {
        cout << "ERROR: Invalid pay code\n";
        status = false;
    }
    else
        status = true;
    return status;
}

double get_pay(char paycode, double hoursWorked, double &payRate)
{
    double totalPay{0};
    if (hoursWorked > NORM_HOURS)
    {
        totalPay =
        payRate * NORM_HOURS +  payRate *(hoursWorked - NORM_HOURS) * 1.5;
    }
    else
        totalPay = payRate * hoursWorked;
    
    return totalPay;
}
//end of main function.


Assignment 5b
Programmed by Paul Duckworth
Enter Employee #, Pay Code, Hours:
123 x 23
you have entered the incorrect paycode
ERROR: Invalid pay code
add another employee? (Y/N): y
Enter Employee #, Pay Code, Hours:
123 t 23
Pay rate: $ 17.00 Pay Amount: $ 391.00
add another employee? (Y/N): n
Program ended with exit code: 0
Lol I am Rodger Coleman. It's a made up name trying to stay
Anonymous. But yes I do appreciate the help thanks.
Topic archived. No new replies allowed.