473,398 Members | 2,113 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,398 software developers and data experts.

C++ program to calculate gross pay in dollars

Develop a program that will determine the gross pay for each
of several employees. The company pays "straight time" for the first
40 hours worked by each employee and pays "time-and-a-half" for all
hours worked in excess of 40 hours. You are given a list of the
employees of the company, the number of hours each employee worked
last week and the hourly rate of each employee. your program should
input this information for each employee, and should determine and
display the employee's gross pay.
Mar 6 '17 #1
3 8772
Frinavale
9,735 Expert Mod 8TB
What have you done so far to implement this program?
Have you designed and implemented an "employee" class?
Have you declared an array or list of employees that you will iterate through to calculate their gross pay?


Once you get started, post what you have done so far and explain the problem that you are having so we can help you.


The experts here will give you a hand with any problems you are having but it's unfair to ask them just to write your program for you. Its also unfair to you for them to do so because you won't learn anything if you don't do it yourself.
Mar 6 '17 #2
dev7060
636 Expert 512MB
Well, I coded this as simple as possible. But I agree with @Frinavale.
Post your problem/ code after trying, as directly asking will not help you learning and building logics in programming.

Expand|Select|Wrap|Line Numbers
  1. #include <iostream>
  2. using namespace std;
  3. int main()
  4. {
  5. char name[10]; //For name of the employee
  6. int hours; //No. of hours an employee worked last week
  7. float rate; //Hourly rate of an employee
  8. float gross_pay;
  9. float extra; // Extra amount added to pay
  10. int num; // For number of employees
  11. //Declared variables in separate lines just for explaining purpose
  12. cout<<"Enter the number of employees: ";
  13. cin>>num;
  14. //Loop to input employee data and calculating gross salary
  15. for(int i=1; i<=num; i++)
  16. {
  17. cout<<"\n Enter the details of employee: "<<i;
  18. cout<<"\n Enter name";
  19. cin>>name;
  20. cout<<"\n Enter the number of hours worked last week: ";
  21. cin>>hours;
  22. cout<<"\n Enter the hourly rate: ";
  23. cin>>rate;
  24. extra=0;
  25. if( hours>40)
  26. {
  27.  extra=((hours-40) * (rate + (0.5*rate)));
  28. }
  29.  
  30. gross_pay=(hours*rate)+extra;
  31.  
  32. cout<<"\n Gross pay of the employee is: "<<gross_pay<<"\n";
  33. }
  34.  
  35. return 0;
  36. }
  37.  
  38.  
Mar 6 '17 #3
Frinavale
9,735 Expert Mod 8TB
See, part of the reason why I asked the original poster to reply with details about what they did is because they are using C++ to do this and C++ is an object oriented programing language.

The solution posted does not make use of objects. Is the point of doing this exercise to learn about objects? Or is it is the poster at a point in their learning journey where they are still learning how to input and output details?

Does the poster have problems with class design? Implementation?

Its really not fair to post anything in response until the original poster provides us with more details about their approach so that they can get help with the concepts or errors they need help with....instead of guessing and providing something that may or may not be helpful.
Mar 6 '17 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: Joecx | last post by:
Does anyone know how to give a date (not today's date) and have the program calculate the previous monday's date from it? Any help would be appreciated. Thanks!!!! Joe
4
by: compsci | last post by:
Im tryin to read the hours and payrate for 75 employees from a called file “employee.data”. This is what I have so far. Can anyone help me? #include <iostream> #include <fstream> using...
2
by: hamady2001 | last post by:
Hello everyone this is my first post and I just started my Python class. I am stuck on an assignment...please help I have to redo the below program (from a prior assignment) to include 2 functions...
1
by: ballpen1019 | last post by:
can someone help me to check any problems in this program...i cant run my program.. /* calculate depreciation using one of three different methods */ #include <stdlib.h> #include <stdio.h>...
7
by: habsy | last post by:
The below are the question given; Please help. (Payroll) Write a program that reads the following information and prints payroll statements in show message dialog box. These are the...
1
by: Benjamaish | last post by:
A= 1000 B= 1500 C= 1200 A and C have 50,000 allowance Tax the first 10,000 has 0% the second 10,000 has 10%
3
by: badandy71 | last post by:
i'm writing a java payroll program for class. I am at the end of the program but I can not figure out how to average the gross/net pay of all employees entered. I know that I must create an array...
5
by: neha123 | last post by:
import java.util.*; class emp { int eno; String ename; int ddob, mdob, ydob, ddoj, mdoj, ydoj, yoe, cyear; double basic, hra, trans, medi, cbonus, ded, gsal; double cbonus( int...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.