Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

uter Science CSCI 201 XXXXxX Payroll System - Display Employee Data 1. Display e

ID: 3729433 • Letter: U

Question

uter Science CSCI 201 XXXXxX Payroll System - Display Employee Data 1. Display employees' information to screen 2. DLaPayF TD loyes' informat on to scren according 3. Display employees' information to screen according the 4. Display employees' information to screen according 5. Display employees' information to screen according the 6. Quit the system order of order of hourly rate order of hours worked order of wage the Enter your option 1 ID 123450 123123 125689 110251 101104 100025 Hourly rate 12.5 25.5 8.5 10.3 7.5 8.0 hours 80.0 89.5 112.5 45.0 56.0 40.0 Wage 1000.0 2282.3 956.3 461.3 420.0 320.0

Explanation / Answer

NOTE: Here i am reading student data from user and then stored that data into file.

After that you have to enter input from 1 to 6 according to option it will read data from file and take action.

Progaram code:

/******************************************************************************

Online C Compiler.

Code, Compile, Run and Debug C program online.

Write your code in this editor and press "Run" button to compile and execute it.

*******************************************************************************/

#include <stdio.h>

struct student

{

int id;

float hr;

float hours;

float wage;

};

struct student data[6], data1[6];

FILE *fptr;

void shortData(int opt) {

int i,j;

struct student temp;

if(opt == 2) {

for (i = 0; i < 6; ++i)

{

for (j = i + 1; j < 6; ++j)

{

if (data[i].id > data[j].id)

{

temp = data[i];

data[i] = data[j];

data[j] = temp;

}

}

}

} else if(opt == 3) {

for (i = 0; i < 3; ++i)

{

for (j = i + 1; j < 3; ++j)

{

if (data[i].hr > data[j].hr)

{

temp = data[i];

data[i] = data[j];

data[j] = temp;

}

}

}

} else if(opt == 4) {

for (i = 0; i < 3; ++i)

{

for (j = i + 1; j < 3; ++j)

{

if (data[i].hours > data[j].hours)

{

temp = data[i];

data[i] = data[j];

data[j] = temp;

}

}

}

} else if(opt == 5) {

for (i = 0; i < 3; ++i)

{

for (j = i + 1; j < 3; ++j)

{

if (data[i].wage > data[j].wage)

{

temp = data[i];

data[i] = data[j];

data[j] = temp;

}

}

}

}

}

int main(void) {

  

int i=0, opt;

  

fptr = fopen("std.txt", "w+");

if(fptr == NULL) {

printf("file open failed");

return 0;

}

  

printf("Enter student details: ");

for(i=0; i<6; i++) {

scanf(" %d %f %f %f", &data[i].id, &data[i].hr, &data[i].hours, &data[i].wage);

fprintf(fptr, "%d %f %f %f ", data[i].id, data[i].hr, data[i].hours, data[i].wage);

}

  

  

rewind(fptr);

printf("read from file: ");

for(i=0; i<6;i++) {

fscanf(fptr, "%d %f %f %f", &data1[i].id, &data1[i].hr, &data1[i].hours, &data1[i].wage);

printf("%d %f %f %f ", data1[i].id, data1[i].hr, data1[i].hours, data1[i].wage);

}

  

printf("Enter your option --> ");

scanf("%d", &opt);

  

if(opt >= 6){

return 0;

}

  

if(opt != 1)

shortData(opt);

printf("ID Hourly rate hours Wage ");

for(i=0; i<6;i++) {

printf("%d %f %f %f ", data[i].id, data[i].hr, data[i].hours, data[i].wage);

}

  

return 0;

}

output will display like below example:

Enter your option --> 1   
ID Hourly rate hours Wage
123 34.299999 45.430000 6.300000
345 56.400002 56.299999 788.400024
111 45.200001 66.400002 22.200001   
555 56.230000 11.100000 98.699997   
345 56.299999 66.599998 22.200001   
567 3.200000 342.100006 54.200001