Gross and Net Income Problem

In dire need of help.

Write a program to calculate gross income and net income for all employees in a company. At the end, also print out the total gross, total net, average gross, and average net. Overtime (over 40 hours) should be paid at a time and a half of rate. Income tax is a fixed percentage of 20%.

First, ask the user how many employees he has and then use a count controlled loop to loop through each of his employees to calculate their income. # of employees must not be negative.

My coding so far:

#include <iostream>
using namespace std;

int main()
const double regular_hours = 40;
int employee_name, employee_count, another_employee, hours_worked;
double total_gross, total_net, average_gross, average_net, rate;

cout << "How many employees in this week's payroll?: " << endl; // cout = console output
cin >> employee_count; // cin = console input

if (employee_count == 0 || employee_count < 0) // || = OR
if (employee_count < 0) //
cout << "Sorry, illegal input! Please input again." << endl;

cout << "NO PAYROLL? Great! Goodbye." << endl;

cout << "Please type in employee's name: " << endl;
cin >> employee_name;
cout << "Enter number of hours worked: " << endl;
cin >> hours_worked;
cout << "Enter " << employee_name << "'s rate: " << endl;
cin >> rate;

if (hours_worked > regular_hours)


return 0;

I can't get cin to run after hours worked.
(1) Please use code tags for code samples. (See the first item in the format menu to the right, or put them in manually as [code] and [/code].)

(2) Unless you are in North Korea, employees have names, not numbers, so it would be better to have employee_name as a std::string rather than an int.

(3) You need a for loop around the input and processing for each employee. (In the future, if you want to store them all for later then you can consider arrays (and, ideally, structs).)

(4) For negative employee_count you ask the user to input the value again ... but don't give him/her any way of doing so. Personally, I would leave input checks like this to last and concentrate on the main sequence of calculations first.
Last edited on
Topic archived. No new replies allowed.