Please help send variable output from header file to main.cpp

Here are my codes, hope someone can help. It maybe a little messy, and it does not have many notes as others posted, but I hope it is clear. The program works if I put them in a single main.cpp, but the professor wants me to get the name and the gross payment values from another file, in this case a header file. Please help me get thru this.

main.cpp


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
#include <iostream>
#include "other.h"
using namespace std;
int main()
{
    UserSelect();//method from other.cpp (this actually works fine without the rest of the code).
    GrossPay grs;//grs=gross payment.
    OvertimePay opay;//opay=Overtime payment

    grs.set_values (value1,value2);//set values to class Grosspay variables.
    opay.set_values (temp1,temp2);//set values to class OvertimePay.
    double fed=0,state=0,net=0,Gpay=0;
    short select2;
    Gpay=grs.Gross() + opay.Overpay();
    fed=grs.Gross()*.0765;
    state=grs.Gross()*.0930;
    net=grs.Gross()-state-fed;
 
    cout<<opay.Overpay()<<endl;
    cout<<"Please select which operation would you like to calculate from the list below: \n1.-Federal Tax.\n2.-State Tax.\n3.-Gross Payment.\n4.-Net Payment."<<endl;
    short select2;
    cin>>select2;
    switch(select2)
    {
    case 1:
    cout<<"The Federal tax calculated is:"<<Gpay*.0765<<endl;
    break;
    case 2:
    cout<<"The State Tax calculated is:"<<Gpay*.0930;
    break;
    case 3:
    cout<<"The Gross Payment calculated is:"<<Gpay;
    break;
    case 4:
    cout<<"The Net Payment calculated is:"<<Gpay-state-fed;
    break;
    }
    return 0;
}



other.h


1
2
3
4
5
6
7
#ifndef OTHER_H
#define OTHER_H

void UserSelect();
extern double value1,value2;
extern double temp1,temp2;
#endif // OTHER_H 



other .cpp


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
#include "other.h"
#include <iostream>
using namespace std;
class GrossPay
{
    double Hours, Hwage;
  public:
    void set_values (double,double);
    double Gross() {return Hours*Hwage*52;}
};
void GrossPay::set_values (double x, double y)
{
  Hours = x;
  Hwage = y;
}
class OvertimePay
{
    double Overhours,Overwage;
public:
    void set_values (double,double);
    double Overpay() {return Overhours*Overwage*52;}
};
void OvertimePay::set_values (double w, double z)
{
    Overhours = w;
    Overwage = z;
}

void UserSelect()
{
    char a[7]={'A','n','d','r','e','w','\0'},b[4]={'B','o','b','\0'},c[7]={'C','a','r','l','o','s','\0'},d[6]={'D','a','n','n','y','\0'},e[7]={'E','d','w','a','r','d','\0'};
    char f[8]={'F','r','a','n','c','i','s','\0'},g[6]={'G','r','a','c','e','\0'},h[6]={'H','e','n','r','y','\0'},i[7]={'I','n','f','r','i','d','\0'},j[6]={'j','a','c','o','b','\0'};
    double value1=0,value2=0;
    double temp1=0,temp2=0;
    short select1=0;
    cout<<"Please select the worker from the list below:\n1.-Andrew.\n2.-Bob.\n3.-Carlos.\n4.-Danny.\n5.-Edward.\n6.-Francis.\n7.-Grace.\n8.-Henry.\n9.-Infrid.\n10.-Jacob."<<endl;
    cin>>select1;
    switch(select1)
    {
    case 1:
    cout<<"Working with "<<a<<endl;
    break;
    case 2:
    cout<<"working with "<<b<<endl;
    break;
    case 3:
    cout<<"working with "<<c<<endl;
    break;
    case 4:
    cout<<"working with "<<d<<endl;
    break;
    case 5:
    cout<<"working with "<<e<<endl;
    break;
    case 6:
    cout<<"working with "<<f<<endl;
    break;
    case 7:
    cout<<"working with "<<g<<endl;
    break;
    case 8:
    cout<<"working with "<<h<<endl;
    break;
    case 9:
    cout<<"working with "<<i<<endl;
    break;
    case 10:
    cout<<"working with "<<j<<endl;
    break;
    }
    cout<<"please enter the hours worked during the week.\n";
    cin>>value1;
    cout<<"Please enter the hourly wage in U.S. dollars.\n";
    cin>>value2;
    if (value1 > 40)
    {
        temp1=value1-40;
        temp2=value2*1.5;
        value1=40;
    }

}
this is my program if I put them together in one main.cpp file.

(code)
//Federal Tax 7.65%.
//State Tax 9.30%
//Gross pay is the payment before any deduction.
//Net pay is the amount paid after all deductions

#include <iostream>

using namespace std;

class GrossPay
{
double Hours, Hwage;
public:
void set_values (double,double);
double Gross() {return Hours*Hwage*52;}
};
void GrossPay::set_values (double x, double y)
{
Hours = x;
Hwage = y;
}
class OvertimePay
{
double Overhours,Overwage;
public:
void set_values (double,double);
double Overpay() {return Overhours*Overwage*52;}
};
void OvertimePay::set_values (double w, double z)
{
Overhours = w;
Overwage = z;
}
int main()
{
GrossPay grs;//grs=gross payment!
OvertimePay opay;//opay=Overtime payment
char a[7]={'A','n','d','r','e','w','\0'},b[4]={'B','o','b','\0'},c[7]={'C','a','r','l','o','s','\0'},d[6]={'D','a','n','n','y','\0'},e[7]={'E','d','w','a','r','d','\0'};
char f[8]={'F','r','a','n','c','i','s','\0'},g[6]={'G','r','a','c','e','\0'},h[6]={'H','e','n','r','y','\0'},i[7]={'I','n','f','r','i','d','\0'},j[6]={'j','a','c','o','b','\0'};
int value1,value2;
double fed=0,state=0,net=0,Gpay=0,temp1=0,temp2=0;
short select1,select2;
// Please select the
cout<<"Please select the worker from the list below:\n1.-Andrew.\n2.-Bob.\n3.-Carlos.\n4.-Danny.\n5.-Edward.\n6.-Francis.\n7.-Grace.\n8.-Henry.\n9.-Infrid.\n10.-Jacob."<<endl;
cin>>select1;
switch(select1)
{
case 1:
cout<<"Working with "<<a<<endl;
break;
case 2:
cout<<"working with "<<b<<endl;
break;
case 3:
cout<<"working with "<<c<<endl;
break;
case 4:
cout<<"working with "<<d<<endl;
break;
case 5:
cout<<"working with "<<e<<endl;
break;
case 6:
cout<<"working with "<<f<<endl;
break;
case 7:
cout<<"working with "<<g<<endl;
break;
case 8:
cout<<"working with "<<h<<endl;
break;
case 9:
cout<<"working with "<<i<<endl;
break;
case 10:
cout<<"working with "<<j<<endl;
break;
}
cout<<"please enter the hours worked during the week.\n";
cin>>value1;
cout<<"Please enter the hourly wage in U.S. dollars.\n";
cin>>value2;
if (value1 > 40)
{
temp1=value1-40;
temp2=value2*1.5;
value1=40;
}
grs.set_values (value1,value2);
opay.set_values (temp1,temp2);
Gpay=grs.Gross() + opay.Overpay();
fed=grs.Gross()*.0765;
state=grs.Gross()*.0930;
net=grs.Gross()-state-fed;

cout<<opay.Overpay()<<endl;
cout<<"Please select which operation would you like to calculate from the list below: \n1.-Federal Tax.\n2.-State Tax.\n3.-Gross Payment.\n4.-Net Payment."<<endl;
cin>>select2;
switch(select2)
{
case 1:
cout<<"The Federal tax calculated is:"<<Gpay*.0765<<endl;
break;
case 2:
cout<<"The State Tax calculated is:"<<Gpay*.0930;
break;
case 3:
cout<<"The Gross Payment calculated is:"<<Gpay;
break;
case 4:
cout<<"The Net Payment calculated is:"<<Gpay-state-fed;
break;
}
return 0;
}

(/code)
SI found ways to make functions and classes outside the program on tutoring by a very nice person who helped me last night. The professor told me it was more than what he was asking for , but the code was OK. He said he did not mean to ask for object oriented programming =(. Anyways I've learned a lot making this program. Ended up making headers with their respective cpp files. Although i have not memorized how to do them perfectly yet. I am sure with practice I will get better. =). Thanks to anyone who took the time at least read what I've done.
Topic archived. No new replies allowed.