Computer Science Homework Solutions
Problem
#2810

Input Output Files

I have to write a program to read a text file and create a payroll register.  The register will contain this data:
Employee(print left-justified)
Department
Pay Rate
Exempt
Hours worked
Base pay(pay rate * hours worked)
Overtime pay (for nonexempt employees.  An employee is exempt if Y appears in the exempt column.  Overtime is paid at time and one half for all hours worked over 40)
Total pay.  

So I did the text file and it's in a table.  I started the input output file and I get an error.  I'm not sure what else I have to do.

Attached file(s):
Attachments
input.txt  View File
iofile.txt  View File

Attachment Content Summary (Note: view attachment at the above link before purchasing. Actual attachment content may vary slightly from that shown below.)

input.txt
Employee No. Department Pay Rate Exempt Hours Worked
============ ========== ======== ====== ============
0101 41 8.11 y 49
0722 32 7.22 N 40
1273 23 5.43 y 39
2584 14 6.74 N 45
iofile.txt
#include
#include

#define BUFSIZE 100

int main(void)
{

FILE *fp;

char buf [BUFSIZE];
int c;
int closeStatus;
FILE *fpIn;
FILE *fpOut;

printf("Begin file copy\n");

if ((fpIn=fopen ("input.txt", "r")))
{
printf("Error in opening input.txt for reading");
return (1);
}
if ((fpOut=fopen ("input.txt", "w")))
{
printf("Error opening input.txt for writing");
return (2);
}
while((c = fgetc(fpIn)))
fputc(c, fpOut);

fclose(fpIn);
closeStatus = fclose(fpOut);
if (closeStatus==EOF)
{
printf("File close error.\a\n");
return 201;
}

printf("File successfully created\n");
return 0;
}
Solution
What is this?
By OTA - Overall OTA Rating
Rong Jiang, MEng (IP) - 1/5
Purchase Cost Now
$2.19 CAD (was ~$3.99)
Included in Download
  • Plain text response
$2.19 Instant Download
Add to Cart
Why you can trust BrainMass.com
  • Your Information is Secure
  • Best Online Academic Help Service
  • Students find real academic Success
Related Solutions
  • Which type of database (distributed, centralized or decentralized) to use? - Consider the following normalized relations for a database in a large retail store chain: EMPLOYEE(Emp_Id, Work_Location, Name, Address) STORE(Store_ID, Region, Manager_ID, Square_Feet) DEPARTME ...
  • Questions 1-7 answers provided need SQL's for each. - With the file attached please answer in SQL form the following. Thanks... 1. Which employees (by name) have degrees? (the "answer" is Smith, Johnson and Williams) SELECT at least the employee firs ...
  • Queries - Using the attached database WK5_DB_ACCESS2000.mdb write SQL queries to answer the following questions. 7. Show the employee (by name) that is shortest. 8. Determine the average number of years ...
  • Draw a Class Diagram for this situation - The following situation describes a company who would like to implement an information system. The company would like to keep track of its employees, departments, and projects. Suppose that the MIS de ...
  • Flowchart and Pseudo Codes - Please assist with the following problems. I am having a few issues getting started. See attached file for full problem description.
Browse