Answered step by step
Verified Expert Solution
Question
1 Approved Answer
WRITE CODE IN C++ . Q6: Consider the following structure definitions: struct Employee struct Address char city [20]; int postcode; char email_id[20]; char name [20];
WRITE CODE IN C++ .
Q6: Consider the following structure definitions: struct Employee struct Address char city [20]; int postcode; char email_id[20]; char name [20]; int scale; Salary YearlySalary[3]; Tax YearlyTax [3]; Address addr; Employee* next; struct Tax struct Salary int Year; float gross salary; int Year; float tax due; float net salary; Write a C++ program that asks the user to enter data for 10 employees. The following information should be entered by the user: name, scale (1 to 17), gross salary for the last 3 years, and address. The program should calculate the yearly tax (5% of gross salary for scale 1 to 10 employees and 7.5$ for scale 11 to 17) and net_salary (gross_salary - tax_due). For an employee, the structure variable should be allocated dynamically on heap memory using new operator. A pointer emp_ptr (of employee type) should be used to point to the first employee (initially emp_ptr will be NULL). The second employee should be referred by the first employee (Employee* next structure member). This will result in a chain of records in the heap (linked with each other using next pointer) as shown below. emp_ptr THL First employee Reference to the next Employee Null = end of linked list Next, find the "average" net_salary for all the 10 employees. Also, display the name and address of the employee who has paid the highest tax (for any year).
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