Write a C program that does/has the following:
1) Create a structure named “employee” that contains the following fields: name (string), id (int), salary (float) and a pointer to the next list item.
2) Create a structure that extends the “employee” structure named “manager” that will contain an additional field for an array of pointers that will point to the employees that they manage, each manager will manage 3 employees.
3) Read the text file provided with this assignment to create and fill the appropriate structures and then create two linked lists, one for regular employees and one for managers. The text file will follow this format, where the type will indicate if they are a manager or not (1 = manager, 0 = regular employee), if they are a manager then the IDs of the people they manage will be listed below that.
name
Id
Salary
Type
EmployeeID1 EmployeeID2 EmployeeID3
4) Print the structures
//
//
//
//
//
data.txt
Bob 102 50000.00 0 Sally 103 40000.00 0 Dan 104 60000.00 0 Chad 105 20000.00 0 Jane 106 90000.00 0 Bucky 107 90000.00 0 Jim 100 200000.00 1 102 104 106 Kyle 109 100000.00 1 103 105 107
#include <stdio.h> //To use printf(), scanf()
#include <string.h> //To use string (%s)
#include <stdlib.h> //To use malloc
// Sturcture for employee
struct employee
{
char name[30]; //Name of employee
int id; //ID of employee
float salary; //Salary of employee
int decision; //If an employee is a manager then
decision=1
}employee;
// Sturcture for manager
struct manager
{
struct employee; // Properties of employee(name, id,
salary, decision) is extended from employee
int ids[3]; // Ids of employee under manager
struct manager* next; // Pointer to the next
employee/manager
};
struct manager* head=NULL; // Starting address(pointer) to the
linked list
struct manager* head2=NULL; // Temporary pointer to the
employee/manager node
void push(char x[30], int y, float z, int w){ //Function to push
elements to employee/manager node
if(head==NULL){ // Check if the starting address of
linked list is NULL
struct manager *temp=(struct
manager*)malloc(sizeof(struct manager)); // Allocate memory for
structure manager
head=temp; // Address to the first
node is assigned to head
head2=temp; // Address to the first
node is assigned to head2
for (int i = 0; i < 30; ++i) //
loop to copy character array
{
(*temp).name[i]=x[i];
}
(*temp).id=y; // id is copied to
structure
(*temp).salary=z; // salary is
copied to structure
(*temp).decision=w; // decision is
copied to structure
if (w==1) // Check if the employee
is a manager
{
printf("Please
enter ids of 3 employee->\n"); // Ask to enter ids of employees
under manager
scanf("%d%d%d",&(*temp).ids[0],&(*temp).ids[1],&(*temp).ids[2]);
// Scan ids
}
(*temp).next=NULL; //The current
node is not pointing another node
//top++;
}
else{
struct manager *temp=(struct
manager*)malloc(sizeof(struct manager)); // Allocate memory for
structure manager
(*head).next=temp; // Node joint at
end of liked list
head=temp;
for (int i = 0; i < 30; ++i) //
loop to copy character array
{
(*temp).name[i]=x[i];
}
(*temp).id=y;
(*temp).salary=z;
(*temp).decision=w;
if (w==1)
{
printf("Please
enter ids of 3 employee->\n");
scanf("%d%d%d",&(*temp).ids[0],&(*temp).ids[1],&(*temp).ids[2]);
}
(*temp).next=NULL;
}
}
void display(){ // Function to print information of linked
list
struct manager* temp;
temp=head2;
printf("The output is.\n\n");
if(temp==NULL){
printf("There is no element(s) in
stack.\n\n");
}
else{
while(1){
printf("Name=
%s\n ",(*temp).name);
printf("ID=
%d\n",(*temp).id);
printf("Salary=
%f\n",(*temp).salary);
//printf("%d\n",(*temp).decision);
if
((*temp).decision==1)
{
printf("%s is a manager and its employees
are:-\n", (*temp).name);
printf("%d %d
%d\n",(*temp).ids[0],(*temp).ids[1],(*temp).ids[2]);
}
else{
printf("\n");
}
temp=(*temp).next;
if((*temp).next==NULL){
printf("Name= %s\n ",(*temp).name);
printf("ID= %d\n",(*temp).id);
printf("Salary= %f\n",(*temp).salary);
//printf("%d\n",(*temp).decision);
if ((*temp).decision==1)
{
printf("%s is a manager and
its employees are:-\n", (*temp).name);
printf("%d %d
%d",(*temp).ids[0],(*temp).ids[1],(*temp).ids[2]);
}
else{
printf("\n");
}
temp=(*temp).next;
break;
}
}
}
}
int main(){
char ch='y';
while(ch=='y'){ // Decide if user wants to add more
employees
char name[30];
int id;
float salary;
int decision;
fflush(stdin);
printf("Enter name of the
employee-> \n");
scanf("%s",&name);
fflush(stdin);
printf("Enter id of the
employee-> \n");
scanf("%d",&id);
printf("Enter salary of the
employee-> \n");
scanf("%f",&salary);
printf("Is employee a
manager(1/0)-> \n");
scanf("%d",&decision);
push(name, id, salary, decision); // Call push function to push data to linked list
fflush(stdin); // Empty input
buffer because next scan is a character
printf("%s\n","Do you want to
enter detail for another employee(y/n)?" );
scanf("%c",&ch);
}
display();
return 0;
}
Write a C program that does/has the following: 1) Create a structure named “employee” that contains...
Java
Do 68a, 68b, 68c, 68d. Show code & output.
public class Employee { private int id; private String name; private int sal; public Employee(int id, String name, int sal) { super(); this.id = id; this.name = name; this.sal = sal; } public int getid) { return id; } public void setId(int id) { this.id = id; } public String getName() { return name; public void setName(String name) { this.name = name; } public int get Sall) { return sal;...
Write a C++ program Write a class named Employee that has the following member variables: name A string that holds the employee name idNumber An int to hold employee id number department A string to hold the name of the department position A string to hold the job position The class will have three constructors: 1. A constructor that accepts all the internal data such as: Employee susan("Susan Meyers", 47899, "Accounting", "Vice President"); 2. A constructor that accepts some of...
Create a C# Console program. Add a class named Employee that has the following public fields: • Name. The name field references a String object that holds the employee’s name. • IDNumber. The IDNumber is an int that holds the employee’s ID number. • Department. The department field is a String that holds the name of the department where the employee works. • Position. The position field is a String that holds the employee’s job title. Once you have written...
Structures in C++ :- 1. Write a program that declares a structure to store the code number, salary and grade of an employee. The program defines two structure variables, inputs record of two employees and then displays the record of the employee with more salary. 2. Write a program that declares a structure to store the distance covered by player along with the time taken to cover the distance. The program should input the records of two players and then...
DROP TABLE EMPLOYEE;
DROP TABLE JOB;
DROP TABLE EMP;
DROP TABLE EMP_1;
DROP TABLE EMP_2;
CREATE TABLE JOB(JOB_CODE CHAR (3) PRIMARY KEY, JOB_DESCRIPTION
VARCHAR (20) NOT NULL,JOB_CHG_HOUR NUMBER (5,2) NOT
NULL,JOB_LAST_UPDATE DATE NOT NULL);
INSERT INTO JOB
VALUES('500','Programmer','35.75','20-Nov-2017');
INSERT INTO JOB VALUES('501','System
Analyst','96.75','20-Nov-2017');
INSERT INTO JOB VALUES('502','Database
Designer','125.00','24-Mar-2018');
CREATE TABLE EMPLOYEE(EMP_NUM CHAR (3) PRIMARY KEY,EMP_LNAME
VARCHAR (15) NOT NULL,EMP_FNAME VARCHAR (15) NOT NULL, EMP_INITIAL
CHAR (1),EMP_HIREDATE DATE NOT NULL,JOB_CODE CHAR (3), EMP_YEARS
NUMBER (2),FOREIGN KEY (JOB_CODE) REFERENCES JOB (JOB_CODE));
INSERT...
Java Description Write a program to compute bonuses earned this year by employees in an organization. There are three types of employees: workers, managers and executives. Each type of employee is represented by a class. The classes are named Worker, Manager and Executive and are described below in the implementation section. You are to compute and display bonuses for all the employees in the organization using a single polymorphic loop. This will be done by creating an abstract class Employee...
I have written my code for an employee management system that stores Employee class objects into a vector, I am getting no errors until I try and compile, I am getting the error: C2679 binary '==': no operator found which takes a right-hand operand of type 'const std::string' (or there is no acceptable conversion). But I am not sure why any help would be great, Thank you! 1 2 3 4 5 6 7 8 9 10 11 12 13...
PL/SQL Auction Program 1. Create a user xyz, who is the owner of the auction. Create the schema, and package. 2. Create users x1 and x2 who are the participants in the auction. They will need acces to the package. 3. Bid on the same item and record your observations. Verify all scenarios. Upload the files with the missing code and a detailed sample run. AUCTION OWNER.TXT SQL> conn / as sysdba Connected. SQL> drop user xyz cascade; User dropped....
I need help with this program c++ - console aplication The attached file is a list of all the Long Island Railroad stations. Each station is described on one line with six space-delimited fields. Each station has a unique 3-character numeric ID, a station name, a branch to which it belongs, a list of the IDs of other stations to which it connects, the station's longitude and latitude, and a final field describing the source of the information. Write a...
okay so here is my c++ code and the errors im really stuck on
fixing what i did wrong it seems to be the same repeated
error
our job is to write a menu driven program that can convert to display Morse Code ere is the menu the program should display Menu Alphabet Initials N-Numbers - Punctuations S = User Sentence Q- Quit Enter command the user chooses A your program should use a loop and your morse code printing...