Write a definition for a structure type for records consisting of a person\'s wa
ID: 3720319 • Letter: W
Question
Write a definition for a structure type for records consisting of a person's wage, accrued vacation (which is a whole number of days), and status (which is hourly or salaried). Represent the status as one of the two char values 'H' and 'S'. Name your new data type EmployeeRecord.
Write a main method that has several EmployeeRecord variables. Some should be initialized with values of your choice. For others, you should prompt the user for information to store. Once you have stored the information in a struct variable, for each salaried employee, calculate the total extra compensation they would receive if the company decides to reimburse them $200 per accrued vacation day and display this on the screen.
Bonus:
Create an array of 10 EmployeeRecord variables, filled with meaningful information. Use a loop to go through the array. Determine if each employee is salaried. If he is, calculate the total extra compensation he would receive if the company decides to reimburse him $200 per accrued vacation day and display this on the screen. In addition, calculate the total amount of money the company will have to pay out for such compensation to all salaried employees in the array.
Explanation / Answer
Answer::
#include <stdio.h>
struct employee{
char name[30];
int empId;
float salary;
};
int main()
{
struct employee emp;
printf(" Enter details : ");
printf("Name ?:");
gets(emp.name);
printf("ID ?:");
scanf("%d",&emp.empId);
printf("Salary ?:");
scanf("%f",&emp.salary);
printf(" Entered detail is:");
printf("Name: %s" ,emp.name);
printf("Id: %d" ,emp.empId);
printf("Salary: %f ",emp.salary);
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.