Visual C++ :: Employee Payroll - Read Data From Text File And Sort
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
ADVERTISEMENT
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
Feb 12, 2013
I am suppose to make a program that reads in data from a text file (integers only) and sorts them as it inserts them into an array of size 10. I did this using an insertion sort, which worked great. But now I am being told that I need the function has to read ALL of the numbers in the text file, not just the first 10, and I am not allowed to store them THEN sort, it has to be sorted as being stored.
This is what I have for sorting first 10
void sortArray(int iArray[])
{
string fileName = "";
fstream inFile;
int tmp = 0;
[Code]....
View 3 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
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
Jul 15, 2014
How to search for a word in a text file and replace it with a new one. Such as employee address, or first name, etc.
Here's my code:
#include <iostream>
#include <string>
#include <fstream>
using namespace std;
int main(){
ifstream inFile; //declare ifstream as inFile and ofstream as outFile
[Code] ....
It is under choice 3, most of my program runs correctly but I am just stuck at this part.
View 3 Replies
View Related
Mar 25, 2013
I am trying to read an array values from Tmin.txt file. I take array size from user viz. number of raw & column and then, read the following data from Tmin.txt file which look like this:
20 40 20 25 30
20 30 40 20 25
20 40 20 25 30
20 30 40 20 25
30 40 40 30 40
I am using getline, and then converting it to int by using atoi. But my code is not working.
Code :
// reading a text file
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
[Code] ....
View 10 Replies
View Related
May 12, 2014
I am having trouble in reading data from my text file and print it out exactly like how it looks like in the text file. The problem im having is it will not read the last y Coordinates of the point. it keep reading the second last point for y coordinates which is wrong.
my text file is
0.0 0.0
0.0 1.0
1.0 0.0(but it read until here)
0.0 0.0(suppose to read the last point which is here)
For your information, this is my 1st year degree assignment in C programming. It is to create a program which can read text file (manually create) and print it out in a program and calculate the area for the polygon using ADT function ( .c and .h files)
*This is the code for my read file function*
Basically this accepts a Polygon and a file pointer as parameters. It reads the polygon point data from the file, pass the read data to plg_new() to create a new Polygon and returns the new Polygon created.
Code:
polygon *plg_read(polygon *New_polygon, FILE *Coord) {
int i;
int numberofvertices=0;
int count=0;
char filename[50];
double xCoor[50], yCoor[50];
[Code]....
This is the second function my polygon new code. This ADT function basically creates a new Polygon with malloc(), initialize all ADT data members with its parameter values and returns the Polygon.
Code:
polygon *plg_new(double *xCoordinates, double *yCoordinates, int numberOfVertices) {
int x;
polygon *New_poly = (polygon *)malloc(sizeof (polygon));
if(New_poly->xCoordinates == NULL || New_poly->yCoordinates == NULL) {
free(New_poly);
[Code]....
This is the rest of the code if you need to refer to other codings.
Code:
/**
*@file polygon.c
*@brief Functions for polygon / Struct has polygon numberOfVertices, polygon *xCoordinates and polygon *yCoordinates
*@author: Tan Xian Yao
*@id: 4323440
*@date: 22/04/2014
*/
[Code]...
View 6 Replies
View Related
Nov 5, 2013
I am in an "intro" C++ course and am having trouble with a section of my current project.
We are required to open a text file, read the data from that file, and print it back.
However, we are supposed to let the user input the name of the file that is to be opened. This is the code I have so far. It is not opening anything.
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
const int NUM_QUESTIONS = 30;
typedef char CharArray[NUM_QUESTIONS];
string fileName;
[Code]...
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
Apr 15, 2013
I am doing an exercise that reads in a text file and loads the data into a struct. My problem is it doesn't read anything from the text file. I think it's the way I'm loading the data. Oh, it does read in the first record that tells the program how many contributor records to create, but nothing after that. Here it is:
Code:
//
#include <iostream>
#include <fstream>
#include <cstdlib>
const int strsize = 30;
const int SIZE = 60;
struct contributions {
char fullname[strsize]; //name
double donation; //donation
[Code] ....
Here is the record input:
Data file:
4
Suz Stuz
55000
Froco Frock
5000
Yandi Yuck
100500
Dippy Dip
120000
9 records - each struct has two members; full name and donation. First record should be number of contributors ...
View 12 Replies
View Related
Oct 21, 2012
Text file can conain one or three integer values in string. How correctly and simplicity read this string?
View 1 Replies
View Related
Sep 28, 2014
I'm new to programming and i'm trying to do a certain task. I want to use a for loop to read certain data from a txt file and print them to a console. I'm trying to read student names and their grades.
Something like
3 // 3 represents the number of students.
George 97
Sarah 70
Maya 88
The data may vary but it's always in this format.
View 14 Replies
View Related
Sep 24, 2012
I want to display data from text file in list view and in tree view root will be file name, but i dont know how to do it, the problem is with displaying text file data in list view, i don't know anything about that. text file data is very simple. It is just a square matrix of double values like:
21.06 34.06 5.0
12.78 45.25 6.9
12.89 45.98 5.5
in list view i want to display it.
View 14 Replies
View Related
Dec 26, 2013
I am writing a program where I need to read a byte of char data and convert it into a text string of binary data that represents the hex value...
i.e. The char byte is 0x42 so I need a string that has 01000010 in it. I've written the following subroutine....
------------- My Subroutine ----------------------------------------------------------------------
void charbytetostring(char input, char *output){
int i, remainder;
char BASE=0x2;
int DIGITS=8;
char digitsArray[3] = "01";
[Code] ....
When I submitted the byte 0x42 to the subroutine, the subroutine returned to the output variable 01000010... Life is good.
The next byte that came in was 0x91. When I submit this to the subroutine I get garbage out.
I am using a debugger and stepped through the subroutine a line at a time. When I feed it 0x42 I get what I expect for all variables at all points in the execution.
When I submit 0x91 When the line remainder = input % BASE; gets executed the remainder variable gets set to 0xFFFF (I expected 1). Also, when the next line gets executed..
input = input / BASE; I get C9 where I expected to get 48.
My question is, are there data limits on what can be used with the mod (%) operator? Or am I doing something more fundamentally incorrect?
View 6 Replies
View Related
Sep 14, 2012
I have tried different programs and nothing works for this.Write a program that will read the gross salary of an employee and calculate the net
View 1 Replies
View Related
Jan 25, 2014
So I need to read in a .txt file and sort it by SSN in ascending order. How to start this but here's what I have so far:
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
struct Information {
char name[25];
long SSN;
[Code] .....
Also here is the contents of the .txt file:
Matthews,Jocob
459237148
19
3930 4th Blvd, Yourcity, NJ 88710
......
and so on.
View 1 Replies
View Related
Jul 4, 2013
I want to autogenerate employee id when user enters details of employee
Conditions:
User Selects Department which should be used as prefix.
A new Sequence of numbers must be generated for each department
Example:
DeptA0001
DeptA0002
Again DeptB new seuquence must be started
DeptB0001
DeptB0002...
View 3 Replies
View Related
May 31, 2013
I am trying to get text file and read only first 100 lines of the text content using c/c++. how can i do it?
is it something like string line;
getline(stream,line);
??
View 7 Replies
View Related
Dec 24, 2013
I have a text file like this
0 1 2 C
10 1 2 S
7 1 2 C
11 1 2 S
9 3 43 C
10 3 43 S
1 3 43 C
101 3 43 S
with this code
ifstream in("fout2.txt");
if (in) {
vector<string> lines;
string line;
while (getline(in, line))
[Code] ....
I obtain this result
0 1 2 C
1 3 43 C
10 1 2 S
10 3 43 S
11 1 2 S
101 3 43 S
7 1 2 C
9 3 43 C
but i want a result like this :
0 1 2 C
1 3 43 C
7 1 2 C
9 3 43 C
10 1 2 S
10 3 43 S
11 1 2 S
101 3 43 S
View 3 Replies
View Related
Mar 23, 2014
I was asked to create a program to find word frequencies, word length in a text file. I am able to use map to do the frequencies part but don't know how to sort the the output accordingly to the length of the words. The example output that I should get is
1 a. 362
i. 157
2 an. 122
at. 201
3 add. 2
age. 1
int main(void) {
static const char* file = "demo.txt";
map<string, unsigned int> wcount; {
ifstream fileStream(file);
[Code] .....
View 10 Replies
View Related
Sep 26, 2014
I'm trying to write a program that will print the data of 10 records from a file and then, sort them descending to ascending by year.
Here are the records:
NameYearTuition
David20111582.38
Sylvester2012728.82
Ben19920
Brandon1995500.25
Riley1997845.19
Mark2009700.05
Roberts2002450.87
Butler2005920.78
Steve20001000.00
Joe19941200.15
Here is my code so far:
#include "stdafx.h"
#include <iostream>
#include <fstream>
#include <string>
using namespace std;
int main () {
string line;
[Code] ....
How do I go about arranging it?
View 1 Replies
View Related
Sep 26, 2014
I'm trying to write a program that will print the data of 10 records from a file and then, sort them descending to ascending by year.
Here are the records:
NameYearTuition
David20111582.38
Sylvester2012728.82
[Code].....
View 6 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
Apr 19, 2013
I want to input data into text file while not deleting the original data in the file and I use something as
ofstream writefile;
writefile.open("example1.txt");
if (writefile.is_open()) {
for(j=0; j<N; j++) {
[Code] ....
But this will delete the original data.
View 3 Replies
View Related
Nov 7, 2014
This refers to an ATL COM DLL project. I can successfully create a class hierarchy of objects, ie. say, one class is the TEAM, which then holds other objects, say, a leader and a secretary, both of which are Employee Classes . Here goes my question:
a) In the Team.h header file I declare m_pLeader as a CComPtr<IEmployee>
Code:
classATL_NO_VTABLE CTeam :
public CComObjectRootEx<CComSingleThreadModel>,
public CComCoClass<CTeam, &CLSID_Team>,
public IDispatchImpl<ITeam, &IID_ITeam, &LIBID_BUOBJ05Lib, /*wMajor =*/ 1, /*wMinor =*/ 0>
{
private:
CComPtr<IEmployee> m_pLeader;
CComPtr<IEmployee> m_pSecretary;
b) The Employee Class is defined within this ATL COM project.
c) In the Team.cpp file, I create an instance in the FinalConstruct code, the focus is on the CEmployee
Code:
HRESULT CTeam::FinalConstruct(){
CComObject<CEmployee>* pLeader;
HRESULT hr=CComObject<CEmployee>::CreateInstance(&pLeader);
if (FAILED(hr))
return hr;
m_pLeader=pLeader;
// ..same for secretary...
return S_OK
}
d) Here comes my QUESTION: How must I proceed if the Employee object was part of another ATL COM DLL, that is it would be described in another DLL that I would now like to reuse? I guess I need to
1. Have the other DLL's idl-, tlb, and h file in my project folder. Let me name it "other.h, other.idl, other.tlb"
2. Both h- and cpp-file must have an #include "other.h" statement -- please correct if I am wrong..
3. ...but how must in the Team's h- and cpp-files the statements be (assuming the class in the "other" Dll is Member (instead of Employee? I know the following code will NOT work, so I am asking how it should be correctly?
Code:
private:
CComPtr<IMember> m_pLeader;
4. and in cpp file for:
Code:
CComObject<CMember>* pLeader;
HRESULT hr=CComObject<CMember>::CreateInstance(&pLeader);
[/code]
View 10 Replies
View Related