- 3

i need help

Develop a C-program that allows user: Adding a new employee Find data about employees using a name inputted. Remove an employee based on a code inputted Print the list in descending order based on salary + allowance.

5th Nov 2020, 12:52 PM
HoĂ ng Long Nguyễn Tráș§n
HoĂ ng Long Nguyễn Tráș§n - avatar
3 Answers
+ 1
#include<Stdio.h> #include <windows.h> #include <string.h> #define MAX 1000 int main(){ char codes[MAX][9]; char names[MAX][21]; double salaries[MAX]; double allowances[MAX]; } char getUserChoice() { int c; printf("1-Add new employee\n"); printf("2-Find data using name inputted\n"); printf("3-Remove employee\n"); printf("4-Print the list in descending order based on salary + allowance.\n"); printf("5-Quit\n"); printf("Choice = "); fflush(stdin); scanf("%c", &c); return c; } void add (char codes[][9],char names[][21], double salaries[], double allowances[], int*pn) { char name[21]; int i, existed; do { printf("Add a employee: "); fflush(stdin); scanf("%20[^\n]", names); existed = 1; for ( i = 0; i < *pn; i++) if (strcmp(names,list[i]) == 0) { printf("Name existed!Retype!\n"); existed = 0; i = *pn - 1; } } while (!existed); strcpy(list[*pn], names); (*pn)++; printf("Added!\n"); system("pause"); system("cls"); } void printBasedName( char name[], char codes[][9],char names[][21], double salaries[], double allowances[], int n) { int i; printf("Searching for : "); char hs[21]; fflush(stdin); scanf("%20[^\n]", &hs); for (i = 0; i < *pn; i++) { nameStr(hs); nameStr(list[i]); char * ptr = strstr(list[i], hs); if (ptr != '\0') printf("RESULT : Name[%d] : %s\n", i, list[i]); } } void removePos (int pos, char codes[][9],char names[][21], double salaries[], double allowances[], int *pn) { search(list, pn); printf("Which Name you want to removed?(input a number) : "); int del, i; scanf("%d", &del); if (del >= 0 && del < *pn) { for (i = del + 1; i < *pn; i++) strcpy(list[i-1], list[i]); printf("Removed!\n"); (*pn)--; } else printf("UnRemoved!\n"); system("pause"); system("cls"); } void sort(char codes[][9], char names[][21], double salaries[], double allowances[], int n) { for (i=
5th Nov 2020, 12:59 PM
HoĂ ng Long Nguyễn Tráș§n
HoĂ ng Long Nguyễn Tráș§n - avatar
+ 1
it not work
5th Nov 2020, 12:59 PM
HoĂ ng Long Nguyễn Tráș§n
HoĂ ng Long Nguyễn Tráș§n - avatar
0
Show your try and provide more details. Don't just copy paste your assignment and expect somebody to do it for you. This is not a homework service!
5th Nov 2020, 12:57 PM
Benjamin JĂŒrgens
Benjamin JĂŒrgens - avatar