Create a file( in Notepad) containing the following names, social security numbe
ID: 3653973 • Letter: C
Question
Create a file( in Notepad) containing the following names, social security numbers, hourly rate, and hours worked. B.Caldwell 163-98-4182 7.32 37 D.Memcheck 189-53-2147 8.32 40 R.Potter 145-32-9826 6.54 40 W.Rosen 163-09-4263 9.80 35 Write a C not C ++ (please) program that reads the data file created above and computers and displays a payroll schedule. The output should list a Social security number, name, and gross pay for each individual. Also print out the name of the individual who makes the most, and the name of the individual who needs a raise (makes the least amount).)Explanation / Answer
please rate -thanks
#include <stdio.h>
#include <conio.h>
int main()
{char name[15],ss[11],mostname[15],leastname[15];
double rate,gross;
int most=-1,least=99999,hours,i;
FILE *input;
input = fopen("input.txt","r");
if(input == NULL)
{ printf("Error opening input file! ");
return 0;
}
printf("name social gross ");
while(fscanf(input,"%s",&name)>0)
{fscanf(input,"%s",&ss);
fscanf(input,"%lf",&rate);
fscanf(input,"%d",&hours);
gross=rate*hours;
if(gross>most)
{most=gross;
for(i=0;i<15;i++)
mostname[i]=name[i];
}
if(gross<least)
{least=gross;
for(i=0;i<15;i++)
leastname[i]=name[i];
}
printf("%-15s%15s%12.2f ",name,ss,gross);
}
printf("%s makes the most %s needs a raise ",mostname,leastname);
fclose(input);
getch();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.