Question
4. Prepare the algorithm and flowchart refer C++ coding bellow #include void getAllEmployee(); void getEmployeeById(); void getEmployeeSalaryLessThan(); void AddEmployee(); void RemoveEmployee(); void GetTotalSalaryForEmployee(); int EmpId[100];
4. Prepare the algorithm and flowchart refer C++ coding bellow
#include
void getAllEmployee();
void getEmployeeById();
void getEmployeeSalaryLessThan();
void AddEmployee();
void RemoveEmployee();
void GetTotalSalaryForEmployee();
int EmpId[100];
int EmpName[100];
int EmpSalary[100];
int EmpGender[100];
int EmpAge[100];
bool isCurrentEmployee[100];
int numberOfEmployees=0;
int EmployeeId=10101;
int main()
{
int yesOrNo=999;
do
{
int choice;
printf("Please choose one of the Choice below: ");
printf("1.Add Employee ");
printf("2.RemoveEmployee ");
printf("3.getEmployeeById ");
printf("4.getEmployeeSalaryLessThan Range ");
printf("5.getAllEmployee ");
printf("6.GetTotalSalaryForEmployee ");
scanf("%d",&choice);
switch(choice)
{
case 1:AddEmployee();
break;
case 2:RemoveEmployee();
break;
case 3:getEmployeeById();
break;
case 4:getEmployeeSalaryLessThan();
break;
case 5:getAllEmployee();
break;
case 6:GetTotalSalaryForEmployee();
break;
}
printf("do you want to continue: yes:1 or No 2");
scanf("%d",&yesOrNo);
}while(yesOrNo==1);
return 0;
}
void getAllEmployee()
{
printf(" =====================================");
printf("All Of the employees are: ");
printf(" Id Name Salary Gender Age ");
for(int i=0;i { printf(" %d %s %d %c %d",EmpId[i],EmpName[i],EmpSalary[i],EmpGender[i],EmpAge[i]); } } void getEmployeeById() { int id; printf(" ====================================="); printf(" Emter the Employee Id you want to see:"); scanf("%d",&id); printf(" The Employee With ID: %d",id); for(int i=0;i { if(EmpId[i]==id && isCurrentEmployee[i]==1) { printf(" %d %s %d %c %d",EmpId[i],EmpName[i],EmpSalary[i],EmpGender[i],EmpAge[i]); } else { printf(" Employee Not Found with Id: %d",id); } } } void getEmployeeSalaryLessThan() { int salaryRange; printf(" ====================================="); printf(" Emter the salary you want to find employees who are getting less:"); scanf("%d",&salaryRange); printf(" The Employee whoose salary lessthan: %d",salaryRange); for(int i=0;i { if(EmpSalary[i] { printf(" %d %s %d %c %d",EmpId[i],EmpName[i],EmpSalary[i],EmpGender[i],EmpAge[i]); } else { printf(" No Employee Have less salary than: %d",salaryRange); } } } void GetTotalSalaryForEmployee() { printf(" ====================================="); int totalSalary=0; for(int i=0;i { if(isCurrentEmployee[i]==1) { totalSalary=totalSalary+ EmpSalary[i]; } } printf(" The Total Salary giving for all Employees is :%d",totalSalary); } void RemoveEmployee() {int id; printf(" ====================================="); printf(" Emter the Employee Id whoom you want to Remove:"); scanf("%d",&id); printf(" Removing Employee : %d",id); int temp=999; for(int i=0;i { if(EmpId[i]==id && isCurrentEmployee[i]==1) { isCurrentEmployee[id]=0; temp=0; } } if(temp==0) { printf(" Removed Employee Successfully!!"); } else { printf(" Employee Not found to Remove!!"); } } void AddEmployee() { EmployeeId=EmployeeId+1; char name[100]; int salary; char gender; int age; printf("Employee Name: "); scanf("%s",&name); printf("Employee salary: "); scanf("%d",&salary); printf("Employee gender: "); scanf("%c",&gender); printf("Employee age: "); scanf("%d",&age); numberOfEmployees=numberOfEmployees+1; EmpId[numberOfEmployees]=EmployeeId; EmpSalary[numberOfEmployees]=salary; EmpGender[numberOfEmployees]=gender; EmpAge[numberOfEmployees]=age; isCurrentEmployee[numberOfEmployees]=1; printf(" Success fully Added Employee: %d",EmpId[numberOfEmployees]); }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started