Need help with void function to calculate payroll

The purpose of this code is to calculate a pagecheck for intered hours and overtime for any hours over 40!


This is what I have so far!



#include<iostream>
using namespace std;
void Amount (int hours, int wage, int sum);
void printCheck(int sum);

int main()
{

int wage,hours;

cout <<" Enter the number of hours you worked"<< endl;

cin>> hours;
wage= 7.25;
void Amount(int hours, int wage, int sum);
void printCheck(int sum);

}
{
void Amount(int hours, int wage, int sum, int overt, int pch int,totsl);
if(hours>= 40);
sum= hours*wage ;

else (hours<40)
total= hours*wage
overt= hours-40
pch= overt*wage*.05
sum= total+pch
}
{


void printCheck(int sum);

cout<<"You worked"<<hours<<endl;
cout <<"Your paycheck total is"<<sum<<endl;


system ("PAUSE");
return 0;
}
Did you even compile your work? This is such a mess. Anyway, please understand my modified code below. Better ask questions if you don't understand so that you can learn something and not just merely copying my 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
#include<iostream>
using namespace std;
double Amount (double hours, double wage);
void printCheck(double sum, double hours);

int main()
{
    double wage, hours, sum;

    cout <<"Enter the number of hours you worked: ";
    cin>> hours;

    wage = 7.25;

    sum  = Amount(hours, wage);
    printCheck(sum, hours);

    system ("PAUSE");
    return 0;
}


double Amount(double hours, double wage) {
    double sum, overt, pch,total;

    if(hours >= 40) {
        sum = hours * wage;
    }
    else if (hours < 40) {
        total = hours * wage;
    }

    overt= hours - 40;
    pch  = overt * wage * .05;
    sum  = total + pch;

    return sum;
}


void printCheck(double sum, double hours) {
    cout << "You worked: " << hours << endl;
    cout << "Your paycheck total is: "<< sum << endl;
}

Last edited on
Topic archived. No new replies allowed.