Payroll program

Hi,I need to create a payroll program for my project. For the assigment i have to create a payroll calculator for 4 types of employees and then the total pay of the company. I think my code works as expected but i don't how to make the [Q] option to work and display the total pay of the company, any tips?.

#include <iostream>
#include <iomanip>

using std::endl;

int main ()
{
int paycode,
hrsworked;
double pay1,
pay2,
pay3,
pay4,
payperwidget,
widgetsold,
weeklysalary,
hrspayed,
commission,
grossweeklysales,
totalpay;

std::cout << std::fixed;
std::cout << std::setprecision(2);

{

std::cout << "(1) Managers" << std::endl;
std::cout << "(2) Hourly Workers" << std::endl;
std::cout << "(3) Commission Workers" << std::endl;
std::cout << "(4) Widget Workers" << std::endl;


std::cout << "Enter Pay code ([Q]uit): ";
std::cin >> paycode;

switch (paycode)
{

case 1:
std::cout << "Manager Selected" << std::endl;
std::cout << "Enter Weekly Salary:$ ";
std::cin >> weeklysalary;
std::setprecision(2);

pay1 = weeklysalary;

std::cout << "Manager's pay is $" << pay1 << endl;
return main();




break;
case 2:
std::cout << "Hourly Worker Selected" << std::endl;
std::cout << "Enter the hourly pay:$ ";
std::cin >> hrspayed;
std::cout << "Enter the total hours worked: ";
std::cin >> hrsworked;

if ( hrsworked <= 40 )
pay2 = hrspayed*hrsworked;

else
pay2 = 40 * hrspayed + ( hrsworked - 40 ) * hrspayed * 1.5;
std::cout << "Hourly worker's salary is $" << pay2 << endl;

return main();

break;
case 3:
std::cout << "Commission worker selected" << std::endl;
std::cout << "Enter Weekly Salary:$ ";
std::cin >> weeklysalary;
std::cout << "Enter Commission (%): ";
std::cin >> commission;
std::cout << "Enter gross weekly sales:$ ";
std::cin >> grossweeklysales;
pay3 = weeklysalary + (grossweeklysales*commission)/100;

std::cout << "Comission worker's salary is $" << pay3 << endl;

return main();
break;
case 4:
std::cout << "Widget worker selected" << std::endl;
std::cout << "Enter pay per widget:$ ";
std::cin >> payperwidget;
std::cout << "Enter number of widgets: ";
std::cin >> widgetsold;
pay4 = payperwidget*widgetsold;

std::cout << "Widget worker's salary is $" << pay4 << endl;
break;

return (main);


}

std::cin.ignore();
std::cin.get();


}

return 0;
}
A few problems:
1) paycode is an int. You can't enter a Q into an int.
2) Recursive calls to main() are not permitted.
3) Line 96, you're trying to return the address of main. I suspect you meant main(), which is still not legal.

PLEASE USE CODE TAGS (the <> formatting button) when posting code.
http://v2.cplusplus.com/articles/jEywvCM9/
It makes it easier to read your code and it also makes it easier to respond to your post.
Hint: You can edit your previous post, highlight your code and press the <> formatting button.

Topic archived. No new replies allowed.