Urgent Help Needed Please!

This is a discussion on Urgent Help Needed Please! within the C Programming forums, part of the General Programming Boards category; I have confused myself added code that is not necessary and left out code. I know what it is I ...

  1. #1
    Registered User
    Join Date
    Nov 2007
    Posts
    69

    Question Urgent Help Needed Please!

    I have confused myself added code that is not necessary and left out code. I know what it is I want to do but am lost on how to get there need. Been working on this for a few days and have little time left.

    Code:
    /*Program will read EmployeeDataFile and create a payroll register containing
     the following information: 
    		a. Employee number (left-justifed)
    		b. Department
    		c. Pay rate
    		d. Exempt
    		e. Hours worked
    		f. Base pay (pay rate * hours worked)
    	Written by: silhoutte75
    		Date: 11/01/07
    */
    
    #include <stdio.h>
    #include <stdlib.h>
    #define _CRT_SECURE_NO_DEPRECATE
    
    //Function Declarations
    	int getEmployData (FILE* spEmployeeData, int* employNum, int* depart, int*payRate,
    						char* exempt, int*hourWork);
    
        void calcPay	  (int payRate, int hourWork, int* payCheck);
    
    	int payrollReg    (FILE* spEmployeeData, int employNum, int depart, int payRate,
    						char exempt, int hourWork, int payCheck);
    
    int main (void)
    {	
    //Local Declarations
    	FILE* spEmployeeData;
    
    	int employNum;
    	int depart;
    	int payRate;
    	char exempt;
    	int hourWork;
    	int payCheck;
    	int* count;
    	int quit;
    
    //Statements
    	printf("Employee files and payroll register\n\n");
    		spEmployeeData = fopen("Data.txt" ,"r");
    		
    		fscanf(spEmployeeData, "&#37;d %d %1.2f %c %d ", &employNum, &depart, &payRate, 
    			&exempt, &hourWork);
    
    		if (!spEmployeeData) 
    		{
    			printf("\aError opening Data\n");
    			return 100;
    		} // if open input
    	
    		while (getEmployData (spEmployeeData, &employNum, &depart, 
    				&payRate, &exempt, &hourWork))
    			{ 
    				calcPay (payRate, hourWork, &payCheck);
    				payrollReg (spEmployeeData, employNum, depart, payRate, exempt,
    					hourWork, payCheck);
    			}// while
    
    		fclose(spEmployeeData);
    
    		printf("\nTo end program type in Q and enter:");
    		scanf_s("%d", &quit);
    
    		return 0;
    }//main
    /*============================getEmployData====================================
    	Reads data from textfile Employee Data.
    		Pre spEmployeeData is opened and recieve employee information.
    		Post	reads employee information
    				reads info -- returns 1
    				EOF or error -- returns 0
    */
    
    int getEmployData (FILE* spEmployeeData, int*employNum, int*depart, int*payRate,
    				    char*exempt, int*hourWork)
    {
    	//Local Declarations
    		int ioResult;
    		*int count;
    
    
    	//Statements
    		ioResult = fscanf(spEmployeeData, "%d-%d-%f-%c-%d %hn", employNum, depart, 
    						   payRate, exempt, hourWork, &count);
    		
    		if (ioResult == EOF)
    			return 0;
    		else if (ioResult != 5)
    		{
    			printf("\aError reading data\n");
    			return 0;
    		}// if
    		else 
    			return 1;
    } // getEmployData
    /*==================================CalcPay====================================
    	Determine employee's pay based on hours worked.
    		Pre payRate, hourWork
    		Post payCheck = payRate * hourWork
    */
    void calcPay (int payRate, int hourWork, int* payCheck)
    {
    	//Statements 
    	*payCheck = (payRate * hourWork);
    	return;
    } // calcPay
    /*=================================payrollReg==================================
    	Writes the employee register including payearned.
    		Pre spEmployeeData is opened retrieving necessary information
    		Post Data Written to file
    */
    
    int payrollReg (FILE* spEmployeeData, int employNum, int depart, int payRate,
    				  char exempt, int hourWork, int payCheck)
    {
    	//Statements
    	printf ("Employee No.	Depart	Exempt	Hours Worked	Pay Check Earned\n");
    	
    	fprintf (spEmployeeData, "%d-%d-%f-%c-%d", employNum, depart,
    				payRate, exempt, hourWork, payCheck);
    	fscanf (spEmployeeData, "%d-%d-%f-%c-%d", &employNum, &depart, &payRate, 
    			&exempt, &hourWork);
    	return 0;
    } // payrollReg
    Please help Urgently needed.

    thank you.
    Last edited by silhoutte75; 11-09-2007 at 08:39 PM. Reason: hide personal info

  2. #2
    Registered User hk_mp5kpdw's Avatar
    Join Date
    Jan 2002
    Location
    Northern Virginia/Washington DC Metropolitan Area
    Posts
    3,789
    First, please take note of the Forum Guidelines post towards the top of the page, in particular this bit:
    3. Do not put URGENT!, or NEED HELP NOW, etc. in your title; it will not make people look at it any faster. Doing this makes many old time helpers on this board not look at the post at all.
    Second, your code is more C than C++ (more appropriate to the other forum).

    Third, you haven't told us what is wrong with your code, just dumped it on the board for others to fix.

    Other than a quick compile, which found this syntax error:
    Code:
    int getEmployData(FILE* spEmployeeData, int*employNum, int*depart, int*payRate,
                      char*exempt, int*hourWork)
    {
        //Local Declarations
        int ioResult;
        *int count;
    ...I'm not going to spend time trying to figure out what it is the code is supposed to be doing versus what it is actually doing.
    "Owners of dogs will have noticed that, if you provide them with food and water and shelter and affection, they will think you are god. Whereas owners of cats are compelled to realize that, if you provide them with food and water and shelter and affection, they draw the conclusion that they are gods."
    -Christopher Hitchens

  3. #3
    Registered User
    Join Date
    Nov 2007
    Location
    Stoneham,Québec
    Posts
    10

    Lightbulb

    Ya I agree this is not C++ lol ... But if it wud be , to put some order in ur code as wut u seem to do is a data base, well you shud make a class for a start and put ur objects in a vector ... wud be a bit more organized and maybe u wud be a bit less confused

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Urgent Help Needed In Writing Algorithm!!
    By Vikramnb in forum C++ Programming
    Replies: 1
    Last Post: 01-09-2009, 11:46 AM
  2. urgent help needed!!!
    By yosef_yaniv in forum C++ Programming
    Replies: 5
    Last Post: 12-08-2007, 11:36 AM
  3. Urgent! Help Needed
    By DarkManiac in forum C++ Programming
    Replies: 4
    Last Post: 04-14-2004, 07:16 PM
  4. Help Needed: Borland C++ 5.5 Installation - URGENT!
    By Linette in forum C++ Programming
    Replies: 12
    Last Post: 03-09-2002, 05:44 PM

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21