Define the following structure in your program and initialize the values after reading from a file “emp.txt”. struct perSalary { int month; /* number 1 is January,2 is February and so on..*/long salary; }; struct employee { int empnr; /* Employee number */ char name[12]; /* Employee name */ struct perSalary salaries[3]; /* three months salaries */ long total; /* Sum of 3 months salaries */ float average;/* Average of 3 months salaries*/ }; A) Using the above structure define an array of structure employee for 4 person that will be initialized using a data file(named emp.txt) which has the following data in it. Using Notepad create the following file 121 Ahmet 2 300000 4 400000 12 750000 234 Ayse 3 250000 6 800000 7 475000 456 Mehmet 4 750000 5 880000 10 660000 875 Sevgi 2 950000 4 660000 9 775000 B) Write a function that displays the initialized values as shown below. Note that the integer values corresponding to months are converted to the proper month names. This can be achieved by declaring an array of the month names. Employee NrNameMonthSalary 121Ahmet February 300000April 400000December750000 234 Ayse March250000June 800000July 475000 456 Mehmet April 750000May 880000October660000 875 Sevgi February 950000 April 660000 September 775000 C) Write a function that computes for each employee the Average and the Sum of the three months’ salaries and sets the values of the corresponding variables in each record and display the output as follows.
Define the following structure in your program and initialize the values after reading from a file “emp.txt”. struct perSalary { int month; /* number 1 is January,2 is February and so on..*/long salary; }; struct employee { int empnr; /* Employee number */ char name[12]; /* Employee name */ struct perSalary salaries[3]; /* three months salaries */ long total; /* Sum of 3 months salaries */ float average;/* Average of 3 months salaries*/ }; A) Using the above structure define an array of structure employee for 4 person that will be initialized using a data file(named emp.txt) which has the following data in it. Using Notepad create the following file 121 Ahmet 2 300000 4 400000 12 750000 234 Ayse 3 250000 6 800000 7 475000 456 Mehmet 4 750000 5 880000 10 660000 875 Sevgi 2 950000 4 660000 9 775000 B) Write a function that displays the initialized values as shown below. Note that the integer values corresponding to months are converted to the proper month names. This can be achieved by declaring an array of the month names. Employee NrNameMonthSalary 121Ahmet February 300000April 400000December750000 234 Ayse March250000June 800000July 475000 456 Mehmet April 750000May 880000October660000 875 Sevgi February 950000 April 660000 September 775000 C) Write a function that computes for each employee the Average and the Sum of the three months’ salaries and sets the values of the corresponding variables in each record and display the output as follows.
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Define the following structure in your program and initialize the values after reading from a file “emp.txt”.
struct perSalary
{ int month; /* number 1 is January,2 is February and so on..*/long salary;
};
struct employee
{
int empnr; /* Employee number */
char name[12]; /* Employee name */
struct perSalary salaries[3]; /* three months salaries */
long total; /* Sum of 3 months salaries */
float average;/* Average of 3 months salaries*/
};
A) Using the above structure define an array of structure employee for 4 person that will be initialized using a data file(named emp.txt) which has the following data in it. Using Notepad create the following file
121 Ahmet 2 300000 4 400000 12 750000 234 Ayse 3 250000 6 800000 7 475000 456 Mehmet 4 750000 5 880000 10 660000
875 Sevgi 2 950000 4 660000 9 775000
B) Write a function that displays the initialized values as shown below. Note that the integer values corresponding to months are converted to the proper
month names. This can be achieved by declaring an array of the month names.
Employee NrNameMonthSalary
121Ahmet February 300000April 400000December750000 234 Ayse March250000June 800000July 475000 456 Mehmet April 750000May 880000October660000
875 Sevgi February 950000
April 660000
September 775000
C) Write a function that computes for each employee the Average and the Sum of the three months’ salaries and sets the values of the corresponding variables in each record and display the output as follows.
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
Step by step
Solved in 2 steps with 3 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY