Write a Program to perform Weekly Department Salary Report program

Whenever a user inputs anything besides a ‘single’ word, the program crashes. I tried using fgets and sscanf, but then it doesnt prompt the user to input anything at all.. Help~ Below is my code. Another question is, how to align the output in a straight line? Everytime the digit is different, the alignment screws up.My code/* A Program to perform Weekly Department Salary Report program*/#include #include #include int main(void){FILE *f;    f = fopen(‘c:\class\pay.txt’,’w’);    if (f == NULL){    printf(‘Error opening file!n’);    exit(1);}char dname[21],ename[100][21],sname[100][21],name[100][21],uantity[5];char artist[21];int credit;int i =0,j,len,bal;float stotal[100],total[100],finaltot, hwage[100],otime[100],owage[100],gross[100],trwork=0,towork=0,trwage=0,towage=0,totwage=0,percent=0;char pay;    char exit =’y’;char output[500] = ”;  printf(‘Mountain Pacific Corporationn’);printf(‘Department Salary Programnn’); printf(‘Please enter the name of the department:  ‘);    scanf(‘%s’,&dname);do{/*    printf(‘Enter employee first name#%d:  ‘,i+1);    scanf(‘%s’,&ename[i]);    printf(‘Enter employee second name#%d:  ‘,i+1);    scanf(‘%s’,&sname[i]);     strcat(ename[i],’ ‘);    strcat(ename[i],sname[i]);       len = strlen(ename[i]);     if (len < 21) for (j = 1; j < (21 - len); j++)strcat(ename[i],'');   *//// The above code still doesn't work.printf('Enter employee #%d: ',i+1);scanf('%s',ename[i]);//scanf('%[^ n]s',ename[i]);  //scanf('%i[^n]', ename[i]);    printf('Enter the hourly wage of %s :',ename[i]);    scanf('%f',&hwage[i]);    printf('Enter total number of hours: ');    scanf('%f',&total[i]);    printf('nnThank you. Process another employee? ');    scanf('%s',&pay);    i = i + 1;   }while (pay == 'y' || pay == 'Y');             fprintf(f,'nnMountain Pacific Corporation');fprintf(f,'nnDepartment Salary Program');fprintf(f,'nnDepartment: %s',&dname);fprintf(f,'nnEmployee                Reg Hrs        Overtime Hrs       Grossn');fprintf(f,'-----------------------------------------------------------------n'); for (j=0;j

Looking for this or a Similar Assignment? Click below to Place your Order

Open chat