Why wont my code go in a loop??

so I have my code and it works fine but I need it to be able to run for an infinite amount of employees or 0 employees. After the function is called for the first employee it will ask for the employee type again but no matter the input it exits with code 0 and I can't figure out why. If someone could point me in the right direction that would be awesome, 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
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
  #include "File.hpp"
#include <iostream>
using namespace std;


double Salaryemp(double x);
double Hourlyemp(double wage, double hr);





void employee_type (signed int& emp)
{
cout << "enter employee type(1 for hourly and 0 for salary or -1 to exit):" <<endl;
cin >> emp;
    
}
int main()
{
    
    double yearsal;
    double hrsal;
    double x;
    signed int emp;
    double z;
    double p;
    
    employee_type (emp);
  
    
    
    if (emp == 1){
       cout << "Enter hours worked this week:"<< endl;
        cin >> z;
        cout << "Enter horly pay:"<< endl;
        cin >> p;
        Hourlyemp(z,p);
        hrsal = Hourlyemp(z,p);
        cout << " The weekly pay is:"   <<double (hrsal) << endl;
       
    }
    
    else if ( emp == 0){
       
       
        cout << "Enter yearly salary:" << endl;
        cin >> x;
        Salaryemp(x);
        yearsal = Salaryemp(x);
        
        cout << "The weekly gross salary is:" << yearsal << endl;
        
      
        
    }
    
    else if (emp == -1){
        return 0;
    }
   
    
    employee_type(emp);
   
    
}






double Hourlyemp(double wage, double hr)
{
   
   
    double hrsal;
    hrsal= hr * wage;
    
   
    
    return hrsal;
}



double Salaryemp(double x)
{
 
   
    

    int weeks =52;
    
    double sal = x / weeks;
    return sal;

   
    
   
    
}



This is updated code since for this project it was supposed to functions passing by reference rather than value. I still need help with the looping but also am wondering am I passing by reference correctly it seemed very similar and since we had a project with passing by value and now by reference, it seemed a little too easy to switch? 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
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
#include "File.hpp"
#include <iostream>
using namespace std;


double Employeesal(double& x);
double Employeesal(double& wage, double& hr);





void employee_type (signed int& emp)
{
cout << "enter employee type(1 for hourly and 0 for salary or -1 to exit):" <<endl;
cin >> emp;
    
    
}
int main()
{
    
    double yearsal;
    double x;
    signed int emp;
    double hr;
    double wage;
    double hrsal;
    employee_type (emp);
  
    
    
    if (emp == 1){
        cout << "Enter hours worked this week:"<< endl;
        cin >> hr;
        cout << "Enter horly pay:"<< endl;
        cin >> wage;
        hrsal = Employeesal (hr,wage);
        
        cout << " The weekly pay is:"   << hrsal << endl;
       
    }
    
   else if ( emp == 0)
    {
       
       
        cout << "Enter yearly salary:" << endl;
        cin >> x;
        
        yearsal = Employeesal(x);
        
        cout << "The weekly gross salary is:" << yearsal << endl;
        
      
        
    }
    
    else if (emp == -1){
        return 0;
    }
   
    
    if (emp == 1 or 0)
    {
        employee_type(emp);
    }
  
    
}






double Employeesal(double& hr, double& wage)
{
    
    double hrsal;
    hrsal= hr * wage;
    
   
    return hrsal;
    
}



double Employeesal(double& x)
{
 
   
    

    int weeks =52;
    
    double sal = x / weeks;
    return sal;

   
    
   
    
}


Topic archived. No new replies allowed.