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.
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.
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)
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);
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++;
I need an array of class objects but am unsure of how one might accomplish this. I have so far...
//element class driver code Element Arsenic(lowCeiling, highCeiling); Element Cadmium(lowCeiling, highCeiling); Element Chromium(lowCeiling, highCeiling); Element Copper(lowCeiling, highCeiling); Element Lead(lowCeiling, highCeiling); Element Nickel(lowCeiling, highCeiling); Element Molybdenum(lowCeiling, highCeiling); Element Mercury(lowCeiling, highCeiling); Element Selenium(lowCeiling, highCeiling); Element Zinc(lowCeiling, highCeiling);
I have Class A as a base class , and Class B , C derived classes from A and there's class D who have a data member (pointer to Array) of type A (Composition)
class D{ A **a; int size; ....... a = new A*[size]; ...... };
And i have Print method , in its body i have to specific element (if it from class B or C ) with a given ID(both B and C have a data member ID ) there should be 2 options in print function .. printing elements for class B , or printing elements for class C ? how can i specific the elements ?
I have a homework requiring me to use quicksort on a pointer array of CDs. They are sorted by the title. I have tried the general solution for integer arrays which sets the pivot at the middle integer but it didn't work/ stopped working when I tried to start sorting the already inputed CDs. The same is happening with the current version (an adaptation of pieces of code):
i want to save similar objects, meaning having same superclass, in an array. Example: I have a superclass vehicle. Class car and truck inherit from vehicle. Now i have a few from both of them an want to put them in an array, vector, set or else. Is this possible in C++ or are there an workarounds? When i remember right, Java and C# offer this feature.
Here again an example:
Code: class vehicle{ int mMaxSpeed; } class truck : public vehicle { int mTrailerLength; } class car : public vehicle {
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.*
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?
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];
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;
What I want to do is have an admin class which will hold all the employee objects, can add them, list and calculate salaries. I'm trying to make array of objects, not sure if it's right
here is the code
Code: #include <iostream> #include <string> using namespace std;
class Employee { public: Employee(string name, short type, int salary)
I am working on building a graph of a maze problem using an adjacency list and my own custom class Node.
Each Node has a vNum and jumpAmount integer variable, the vNum is the unique key.
If I have an array of lists of Node objects declared by: Code: forward_list<Node> adjacencyList[10] I skip the 0 row and only use 1-9. It makes more sense logically for my program and Im not worried about wasted memory at this point.
How could I go about traversing and outputting member variables for all the Nodes in each list in my array?
where the values in brackets are the nodes that have an edge with the ith row node. Had to put it in code tags for the thread to be allowed to post.
I am using the forward_list library for my list functions and this is where my problem arises. The cplusplus.com - The C++ Resources Network website iterates through the list using:
Code: for ( auto it = mylist.begin(); it != mylist.end(); ++it ) std::cout << ' ' << *it;
Obviously this works for ints, doubles, etc, but not objects with member variables. My attempt to replicate this code for my problem looks like:
Code: for( int i = 1; i < 10; ++i ) { cout << "Node " << i << " -> { "; for( Vertex it = adjList[i].begin(); it != adjList[i].end(); ++it ) { cout << it.getVNum() << ", "; }}
I have to come up with user defined conversions for this to work and I have never done such a thing. Is there a way to go about doing this to avoid user defined conversions, because if there isnt I feel like attempting to do this specific problem might be a little too difficult for someone who hasnt defined any custom conversions.
Potentially, I could write my own List class and have a next pointer member variable that points to the next object in the list and use that to use a dot reference to a get function to display member variables. This is how I learned linked lists back in my Data Structures class. However I am trying to avoid that for the time being, as that would be a lot more code to implement rather than just figuring out how to use the forward_list library.
Im supposed to create an to array of eight Circle objects initialized with the following radii: 2.5, 4.0, 1.0, 3.0, 6.0, 5.5, 3.5, 2.0. Then use a bubble sort to arrange the objects in ascending order of radius size before displaying the area of each object.
The error I get is "Cannot open include file: 'Circle.h': No such file or directory". Do I have to create a separate file for it?
#include <iostream> #include <iomanip> #include "Circle.h" using namespace std; class Circle { public: Circle()
I've got an error saying that there is an access violation at 0x0000040 error no 0xC0000005
I've searched the net, saying the error may be due to an uninitialzed variable.I debugged the code, and found out that an object created from directx D3DXMATRIXA16 is uninitialized.With values ??,??,?? in each element
pMeshContainer->pBoneMatrices = new D3DXMATRIXA16[g_NumBoneMatricesMax];
here, pMeshContainer is a variable passed into a function called GenerateSkinnedMesh by pointer
when the method CreateMeshContainer finished execution, the meshContainer is passed back to its parent like this
*ppMeshContainer = pMeshContainer;
The whole meshContainer stuff is stored persistently inside the frame root wrapped within a class called CMesh So in that process, I haven't initialized pBoneMatrices in anyways. But what and where is the best way to initialize an array of DirectX9 objects.
There is a function called
D3DXMatrixIdentity(&...);
But how can I initialize each one of them with this call?
Notice that pMeshContainer->pBoneMatrices does contain a valid address, despite the fact that the elements inside it are never initialized...