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];
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);
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.*
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 am basically trying to make a program for a calculator. I am struggling with how to do the sine calculation. this calculation will take place at line 158.
#include <iostream> #include <cmath> using namespace std; int main() {
I am reading from a text file and want to create a program that will perform the same calculation for every oscillation.
The text file I'm reading from is attached to this post. A3.txt
The program that I've written is as follows:
Code: #include <iostream> #include <fstream> using namespace std; int main() { ifstream inFile ("AP1.txt"); ofstream results_file ("APDuration.txt");
[Code]...
Where I'm having trouble is in having the inFile.seekg function iterate to the next series of values.
Here is what the data file looks like in a graph:
In a nutshell, my program will read the duration of each action potential from a point called "dVmax" (where the upstroke is at its maximum upward rate of change) to the point of 90% repolarization (on the downstroke where 90% of the total wave amplitude is subtracted from the volts at peak amplitude).
If you would like to test my program on one action potential, here is one action potential : AP1.txt
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)
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++;
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 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;
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 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
I tried to write a simple program to calculate monthly yield, APR, and principle in various directions. Anyway, here's some code to get the APR from the principle and monthly yield. When I run it though, it spits 0 at me every time! What the problem is; the other functions work just fine and the code line for the APR calculation is just what it ought to be - I see neither a math nor tech problem here.
Here is the offending function:
Code: void calculateAPR() { int principle, monthlyYield, apr; cout<<" Please input the principle:"; cin>>principle; cin.ignore();
So, I think that the above expression converts to 0x49 | 0x00 ... and the complete expression should be 0x49 for me.
But, the compiler gives me the result of 0x4949 as two bytes.How does the compiler calculate this expression as two bytes?show me the steps included in the calculation of this expression?
I want to have calculations take place inside a switch statement that calls the appropriate function. The menu portion of the program works well, but I can't figure out how to let the user actually input 2 different numbers to the functions. My questions are:
1. If I use scanf to assign values to the variables, what determines end of input to each variable? (ie.. scanf("%d%d", &a, &b) what is the end of a, what is the end of b?)
2. Should I assign the variables to user input inside the switch, or try to do it in the functions below?
3. Is there something I haven't thought to ask that will screw me over? I'm really new to this.
Code: #include<stdio.h> int add(int b, int a); int mult(int b, int a); main() {
[Code] ....
This really was a test of multilayer menu, but I want to add functionality if I can.
Changed a variable before posting and didn't change all the conditions testing it.