C/C++ :: How To Create Payroll System Using Arrays
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;
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?
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.
I have an assignment to create a grading system using multimap. It's not completed yet at the moment but whenever i try to compile it tells me "no match for 'operator[]' in lines 56,57,etc. I
#include <iostream> #include <string> #include <map> using namespace std; class Student { public: //--- Constructor Student (int id = 0, double gpa = 0);
I am trying to create an billing system "without using pointers". This is my class assignment. In this,
1) User inputs the name 2) The system asks how many items he has purchased 3) Displays a bill number [just a random number] 4) System asks for the item names the user purchased and stores them in an array (of max 10 (ten) inputs (or items)) 5) After each item the user inputs, the system asks for the price of the item (stored in an array of numbers) 6) The total bill is calculated, by adding the sum of all prices in the array
I am having terrible difficulties in coding #4 and #5. Somehow, they aren't going well together. Here's what I have:
#include<stdio.h> #include <stdlib.h> int main() { char item[10][10], answer = 'y', name; int price[10], total_item, total_price = 0, i, j, a, total_bill = 0, max_items = 10, max_char = 10;
I wanted to do this: Accept a line of input from user and save it to an array1 and copy its contents to other array in a set of arrays and then input another line to array1 and then copy it to next array in the same set and so on.... I know it is confusing but I can put it like that I want to create an array of arrays (Set of arrays). How can I do so?
I wrote a code to input the line in an array and tried to copy it another array of pointers, but pointers are just addresses so the same adress is copied again and again so, all the pointers of the array point to one address only. The code doesn't print anything when I try to print all the lines that were saved.
Code: #include <stdio.h> #include <stdlib.h>
#define MAXLEN 1000 #define MAXSIZE 100
int getline(char [], int ); void storage(char line[]);
You have to write a single C program that creates a one dimensional array of size MAX(to be declared as a declarative constant using directive #define MAX 10), initializes its elements with a given value using the function InitArray, then populate the array with some random numbers between 1 and MAX inclusive, and finally search the array for certain keys.
The structure for this C program is as follows:
int main() { //array A to be locally declared here int size = MAX; }
This program needs to display a vertical graph of asterisks showing production for each plant in the company ...
Here is what I have so far:
*********************************** This program will read data and display a vertical graph showing productivity for each plant. Reference Display 7.8 pg. 401-3 *********************************** */ #include <iostream>
I'm trying to create a function that uses dynamic allocated arrays instead of vectors because I want to see how they work. Basically, this function asks the user to input how many people they are going to enter followed by their name; then, they enter how many of these people want to register for an ID followed by their phone #.
For example:
"How many customers will you like to enter? " 3 //user inputs 3 Bob Allen //user input Ellen Michaels //user input Jane Andrews //user input
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);
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.
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++;
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'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];
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
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?
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)
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
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
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