C++ :: Payroll System - Visualizing Hierarchy
Apr 27, 2014
I have been given a HW to write code for a payroll system. The base class would be Employee. There are four types of employees.
1 - Salaried (fixed salary, no matter the hours)
2 - Hourly (overtime [>40 hours] pays time and half)
3 - Commissioned (paid percentage of sales)
4 - Base-plus-commissioned (base salary + percentage of sales)
Also add a private data member birthDate (a Date object) and departmentCode, an int to class Employee.
1 - Is the following hierarchy that I'm visualizing right? Or is a change needed?
Here is the link: [URL] ....
2 - In hourly, what does in round brackets mean? What is meant by "pays time and half"?
3 - In base-plus-commissioned, is it required to take "base salary" from user or I just get salary from the salaried employee?
View 5 Replies
ADVERTISEMENT
Feb 21, 2015
Create a payroll program to store and calculate the payroll for a small company with a maximum of 20 employees.
Program parameters are as follows:
1. Create a menu with the following options (use a do-while loop):
A or a to add employee info
D or d to display employee info
T or t to display total payroll
S or s to display the info of all employees
Z or z to exit program
The information for each employee is: employee number, hours worked, pay rate per hour, tax deduction.
2. Use an array of doubles to store employee information.
3. Menu option A or a: ask the user for the employee information one value at . a time and store it in the array.
Please enter employee number: 2190
Please enter hours worked: 32.50
Please enter pay rate: 9.25
Please enter tax rate deduction: 5.50
4. Option D or d: ask the user for an employee number as integer and display . the information for the corresponding employee (cast the employee number
. in the array to integer and then compare). If employee number does not . match, output a msg. indicating "no such employee". If the employee number . is a match, output all the employee information stored in addition to the . calculated deduction and salary.
Output sample:
Info for employee number: 2190
Hours worked: 32.50
Pay rate: $ 9.25
Tax deduction: 5.50 %
Total pay: $ 284.89
5. Option T or t: calculate and output the sum of the total pay of all
. employees.
6. Option S or s: display the information for all employees in the same
. format as in option B.
7. Option Z or z: exit the program.
#include <stdio.h>
#define MAX [20]
int main(void) {
int i;
for (i=0;i<=20;i++) {
char MenuOption=0;
int EmployeeNumber;
[Code] .....
View 1 Replies
View Related
Jun 10, 2014
Just bought a new ST Micro iNEMO-M1 system, and am looking to have my code visually show me the rotation information. I've got a working C++ code which actively acquires data from the sensor, and I'm looking to extend that into some visual interface which will show me on-screen the position of the sensor.
I figure using rotation information in the form of quaternion data is the most useful (want to avoid the gimbal lock problems associated with Roll/Pitch/Yaw).
What would be the best method to visualize the rotation of my sensor in real-time?
View 2 Replies
View Related
Apr 25, 2014
How do we design a container of objects all of which belong to some subclass which directly/indirectly inherits from a given parent class? Moreover, I would like to have functions that enable me to pick only objects of a certain class type from the container.
For example if the parent class is A and I have a hierarchy of classes that derive from it, we must have a container that can contain any class that exists in this hierarchy. Also, get_B() must be able to let me examine only those objects in this container that inherit (directly/indirectly) from class B (class B exists in the hierarchy rooted at A).
Preferably, we would like to avoid downcasting. Or even explicit typechecking of any sort.
View 8 Replies
View Related
May 29, 2013
code:
class BM_FONT_CALL BMfont {
public:
BMfont();
~BMfont();
bool Load(const std::string& fontName);
void Print(float x, float y);
class BM_FONT_CALL BMstring : public std::string
[code]....
How can I do `BMstring` have an access to `BMfont`'s members, as if `BMstring` will not inherit `BMfont`'s members? For example, if I do this:
BMfont::BMstring text;
text.scale //I don't want this
What I want to do here is, I want the `BMstring::Compile()` to have an access to `BMfont` with no any instance of `BMfont` inside `BMstring`.
Or what if I do this:
class BM_FONT_CALL BMstring : public std::string {
std::function<void (void)> func;
public:
BMstring() { func = BMfont::Compile(); }
}
By making the `Compile()` member of `BMfont`.But this won't compile. How can I achieve this?
View 2 Replies
View Related
Jun 6, 2012
I have a hierarchy of Actions (NonMovingActions and MovinActions each with sub-hierarchies). Actions class has an abstract function.
Code:
class Action {
public:
Action(Agent& agent, ...):agent(agent),..{}
virtual ~Action(void);
virtual bool run()=0;
[Code]...
It appears that C++ does not allow this (in Java it was possible). Compiler objects that Action class is abstract (and cannot be instantiated?!)
Code: error C2259: 'Action' : cannot instantiate abstract class
1- May I know what do I not understand here? We cannot refer to sub-class instances with a reference of parent class type?
2- Should I use vector of pointers instead or what?
View 6 Replies
View Related
Aug 24, 2014
My program has a large version of this, where every leaf class is singleton, and pointers of the base class to represent each possible path are stored in a map during compile time. I have it working as follows:
#include <iostream>
#include <string>
#include <map>
[Code].....
But System::initializePrototypes() is constructing the map manually, and I want to use recursion somehow, because my hierarchy is much bigger than this. It's also easy to miss a path doing it the above way, and when new classes are added to the hierarchy, it will be a nightmare to update the map. So the ideal solution is recursion constructing the map perfectly--and when new classes are introduced, nothing needs to be added to System::initializePrototypes().
View 7 Replies
View Related
Aug 6, 2013
I got a mesh which has an edge with a specific transformation (translation + orientation). When this configuration / transformation is changed, its neighbours are to be updated. This structure is kept inside a tree so that when a root "frame" is passed to a method like UpdateHierachy, the mesh will recursively update itself.
If, I don't pass this method the root element, which is in my case, how do I change the rest of the structure? The reason to do this is because I want to say move the door, the windows and furniture will move along with it.
View 8 Replies
View Related
Jun 11, 2014
I have to create a 2D link list with 2 level hierarchy
some thing like that
Code:
head nodes level 1: 0 1 2
/| / /|
Sub node level 2: 0 1 2 0 1 0 1 2
Real Data under |
each sub node: |
int **join=Null;
int unique = 0;
int col;
int ptr;
int *tmp_perm=Null;
int col_elem;
I know how to deal with 1 level link list structure. But i don't know how to access, delete, nodes and sub nodes from this 2 level hierarchy. C
View 4 Replies
View Related
May 15, 2014
Alright, after what seems like forever I'm on the last stage of modifying my Payroll Program. This time I have to sort using pointers and I only have to sort the Net Pay category.
Using one of my earlier programs I've removed content from it until it's in a state where it runs but contains no sorting functions.
So now I've to a working program that lacks any kind of sorting and looks like this.
#include <iostream>
#include <fstream>//file input output stream
#include <iomanip>
#include <string>
using namespace std;
//function prototypes
int readalldata(long int id[], string fname[], string lname[], int hoursworked[], float hourlyrate[], int n);
[Code] .....
My hints for how to add pointers to the program are...
int *np,tmp;
for (i=0,i<n; i++) np=&netpay[i]; //associating the netpay to np;
temp=np[i];//storing the pointer to a temp
I've been fooling around trying to sort the Net Pay by pointers using these hints for a bit now and I'm still not getting it.
View 2 Replies
View Related
Apr 28, 2014
how these structures and arrays work which is why although I added alot more code than given, I sent it into my teacher and he was puzzled with my project. So I brought it back to a payroll calculator unsorted.
Sort the payroll data, and output the data to the file in order by gross pay (lowest to highest)
#include <fstream>
#include <iostream>
#include <cstdlib>
[Code]....
View 5 Replies
View Related
May 15, 2014
My objective is to write a payroll program that among other things sorts the net pay by using pointers. I've already written most the program and have written a working program that sorts the net pay just not by pointers. So What I'll be posting below is my program so far without the pointer sort function.
What I need to do to finish my program is figure out how to add pointers to sort net pay into it.
#include <iostream>
#include <fstream>//file input output stream
#include <iomanip>
#include <string>
using namespace std;
//function prototypes
int readalldata(long int id[], string fname[], string lname[], int hoursworked[], float hourlyrate[], int n);
[Code] ....
View 14 Replies
View Related
May 20, 2014
Define a PayRoll class that has data members for an employee's hourly pay rate (an integer , representing cents) and number of hours worked (also an integer ). The class provides two member functions, setRate and setHours that assign the value of their parameter to the appropriate data member. The class provides a third member function, getPay, that returns weekly gross pay (in cents), computed as follows: hours times rate for the first 35 hours plus hours times rate times one and a half for any hours past 35.
View 3 Replies
View Related
Apr 11, 2014
When you execute my code you'll notice the regular pay for the first example will calculate to $500 when it is only supposed to calculate to $400. I'm also having a problem adding up the totals of the regular pay and overtime pay to get a total payroll which is displayed in one cout statement. 95% of my code is correct, I'm just having these two issues. To make it more clear hear is my assignment:
The regular working hour for an employee is 40 hours a week. Sometimes employees work over time. When the employee works 40 or less hours, the regular pay is calculated as number of hours worked times the hourly rate. When the employee works over time i.e. beyond 40 hours then the employee's pay has two components a) regular pay (40 hours X hourly rate), and 2) overtime pay (the overtime hours beyond 40 X time and half of the hourly rate).
void compute(incomeInfo *ptrI, int count) {
for (int i = 0; i<count; i++)
if (ptrI->hours <= 40) {
ptrI->regPay = ptrI->hours * ptrI->hRate;
ptrI++;
[Code] ....
View 1 Replies
View Related
Dec 9, 2014
The purpose of this code is to calculate a pagecheck for intered hours and overtime for any hours over 40! This is what I have so far!
#include<iostream>
using namespace std;
void Amount (int hours, int wage, int sum);
void printCheck(int sum);
int main()
[code]....
View 1 Replies
View Related
Oct 1, 2014
Make a c++ program of the payroll of a company
input values :
a. Name of Employee
b. Position in the company
c. No. of hours worked
d. No. of overtime hours
e. rate per hour
formula:
basic pay = number of hours worked x rate per hour
ot pay = overtime hours x 150% of rate per hour
gross pay = basic pay + ot pay
tot deduc = tax + sss + med
tax can be computed based on the following table:
basic pay tax
10000 or less 1% of basic pay
10001-15000 2% of basic pay
15001-20000 3% of basic pay
20001-30000 4% of basic pay
30001 or more 5% of basic pay
sss = 10% of basic pay
med = 6% of basic pay
net pay= gross pay - total ded
*The payroll should have at least 5 employees in it.*
View 11 Replies
View Related
May 22, 2014
I'm working on a payroll program and I'm having problems that are causing calculation errors.
My input file is
1234FredJones4025.00
2345 TerrySmith6010.00
The errors I get are from the regular pay, over time pay, gross pay, tax amount and net pay calculations. They all look similar to this (6e+002). I believe they are occurring because regular pay isn't calculating correctly and the rest depend on that for their calculations. However, I can't see why regular pay isn't calculating correctly.
#include <fstream>
#include <iostream>
#include <iomanip>
using namespace std;
class payroll{
ifstream fin;
char employeeid[100];
[Code] .....
View 14 Replies
View Related
Sep 30, 2013
getting output from my code when I compile, the codeblocks ide doesnt show any errors it just doesn't give me any out put when I compile?
Here is my code:
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;
//
//CLASS DECLARATION SECTION
[code].....
View 1 Replies
View Related
Nov 25, 2013
The program is showing zero in output section ....
Code:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SZ = 55;
[Code] ....
The output:
Code:
First Last Employee Hours Rate Regular Overtime Gross
Name Name Number Worked of Pay Pay Pay Pay
==============================================================
Jane Adams A1234 40.00 10.00 0.00 0.00 0.00
Mary Lincoln L8765 50.00 10.00 0.00 0.00 0.00
Martha Washington W7654 25.50 10.85 0.00 0.00 0.00
John Adams A9876 52.00 15.75 0.00 0.00 0.00
George Washington W1235 45.00 25.00 0.00 0.00 0.00
Abraham Lincoln L9087 40.25 55.00 0.00 0.00 0.00
William Tell T9876 30.00 9.75 0.00 0.00 0.00
View 12 Replies
View Related
Jun 9, 2014
This program in not completed. I am creating a large program in order to calculate a company's weekly payroll. For now I am filling in the separate functions piece by piece before the rest of the program is completed.
Right now I am trying to use separate functions to call other functions. I need to ask the user for the file name and then open the file. I am no longer getting any compiler errors however when I run the program all it displays is "Welcome."
So it's not actually calling the NameTheFile function and the OpenTheFile function. It just says "Welcome" and then closes down. Why is it doing this?
/*Program to determine company's weekly payroll*/
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
void NametheFile() {
ifstream inputFile;
[Code] ....
View 1 Replies
View Related
Oct 5, 2014
Write a payroll program that prompts for the number of hours an employee worked, as well as the employee’s pay rate. If the employee worked for 40 hours or less, the gross pay is calculated by multiplying the number of hours worked by the pay rate. If the number of hours worked by the employee exceeds 40 hours, the employee should receive regular pay for the first 40 hours, and receive time-and-a-half pay for the hours in excess of 40. Display the calculated gross pay on the screen.
Continue to prompt for similar data for more employees and have the gross pay of each employee displayed, until there is no more employee data to process. Then display “Good Bye”.
Your solution must be separated into three source files (Interface, Implementation, and Test)
View 3 Replies
View Related
Dec 4, 2014
Basically for homework, we gotta make an array of payroll objects, using the general format I've made below...
I'm having trouble. The .dat file we are given to test looks like this:
40.0 10.00
38.5 9.50
16.0 7.50
42.5 8.25
22.5 9.50
40.0 8.00
38.0 8.00
40.0 9.00
44.0 11.75
When I execute the program, it shows the first column of objects, but will always replace the 2nd column values with a 0.
It's definitely NOT reading that column, and using the constructor to set it to zero. I don't know why it's not reading that column though...
(TL;DR.... Currently it reads "Employee #1: 40, 0" rather than "Employee #1: 40, 10.00"... etc)
Here's my code.... (not 100% done yet just testing datafile output atm)
#include <iostream>
#include <fstream>
using namespace std;
class Payroll {
private:
double payRate; // holds an employee hourly pay rate
[code]....
I want it to read the other column without giving me zero />
View 2 Replies
View Related
Dec 11, 2013
I am writing a employee payroll program using structures. My program is running but its only showing some of the data.
HERES MY CODE
Code:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
#include <cstring>
using namespace std;
const int SZ = 20; // size of arrays to hold scores
struct payrollStruct {
[Code] ....
And it doesn't show anything from txt file
Code:
40.0 10.00 A1234 Jane Adams
50.0 10.00 L8765 Mary Lincoln
25.5 10.85 W7654 Martha Washington
52.0 15.75 A9876 John Adams
45.0 25.00 W1235 George Washington
[Code] .....
View 14 Replies
View Related
Apr 2, 2013
Create an a simple Payroll Management Application using the concept of Binary Tree. The program will allow you to add, sort, view, search record. The application have also the capability to save and retrieve data in a file.
View 1 Replies
View Related
Nov 11, 2013
i tring to write a employee payroll code with functions and read data from the txt. file and also bubble sort that sorts and displays starting from employees last name and calculations.
//txt file//
Hours Pay rate empID first name last name
40.0 10.00 A1234 Jane Adams
50.0 10.00 L8765 Mary Lincoln
25.5 10.85 W7654 Martha Washington
52.0 15.75 A9876 John Adams
45.0 25.00 W1235 George Washington
40.25 55.00 L9087 Abraham Lincoln
30.0 9.75 T9876 William Tell
42.5 12.50 M7654 Missy Muffett
30.0 10.00 P8765 Peter Piper
and here is my code
Code:
#include <iostream>
#include <cstdio>
#include <fstream>
#include <string>
#include <iomanip>
using namespace std;
const int SZ = 55;
void tellUser();
[Code] .....
here are the errors the are giving
Code:
payroll.cpp: In function "int bubbleSort()":
payroll.cpp:52:8: error: "lastpos" was not declared in this scope
payroll.cpp:52:18: error: "numemp" was not declared in this scope
payroll.cpp:56:10: error: "swapmade" was not declared in this scope
payroll.cpp:57:16: error: "i" was not declared in this scope
[Code] ....
View 14 Replies
View Related
Nov 18, 2014
#include <iostream>
#include <string>
using namespace std;
[Code].....
This is my code, when my pintrials = 0, my system cannot terminate but go through the option menu below.
View 1 Replies
View Related