Using Structs within Structs
Refer to the Structure on page 624 in the 7th Edition of the Malik Textbook (link is on this site) which defines EmployeeType as a struc with OTHER structs as its members. You can also refer to p.622 in order to see how to access the information.
=======================================================================================
Design and Implement a program that will read from a file all the elements needed to fill/ INPUT DATA for the entire structure for up to- 5 Employees
OUTPUT: All the contents of the struct.
**PLEASE DO NOT USE VOID FUNCTION IN THIS PROGRAM AND ONLY NECESSARY HEADER FILES..MAKE IT AS SIMPLE AS IT CAN BE**
NOTE: Use #include <iomanip> to format the output of the structure.
An example of how one can access the members of a struct is on p. 626.
This should work for the number of records in the file....
MALIK TEXT BOOK LINK: https://drive.google.com/file/d/0B6viA91V5enRclVLZmxOOUwzUGc/view?ts=59d26687
**PLEASE DO NOT USE VOID FUNCTION IN THIS PROGRAM AND ONLY NECESSARY HEADER FILES..MAKE IT AS SIMPLE AS IT CAN BE**
ans..........................................
Copyable code:
//Include files
#include <iostream>
#include <fstream>
#include <string>
#include <cstdlib>
#include <iomanip>
using namespace std;
//Create structure
struct nameType
{
//Declare variable
string first;
//Declare variable
string last;
};
//Create structure
struct employeeType
{
//Declare variable
nameType name;
//Declare variable
int performanceRating;
//Declare variable
int pID;
//Declare variable
string dept;
//Declare variable
double salary;
};
//Declare variable
employeeType employees[25];
//Declare variable
employeeType newEmployee;
//define function
int main()
{
//Declare variable
int cnt=0;
//Declare variable
ifstream fID;
//Open file
fID.open("inp.txt");
//Check condition
if(fID.is_open())
{
//Read name
while(fID>>newEmployee.name.first>>newEmployee.name.last)
{
//Read value
fID>>newEmployee.performanceRating;
//Read value
fID>>newEmployee.pID;
//Read value
fID>>newEmployee.dept;
//Read value
fID>>newEmployee.salary;
//Read value
employees[cnt] = newEmployee;
//Increment value
cnt++;
}
//Close file
fID.close();
//Print message
cout<<"Displaying Employees details:"<<endl;
//Loop
for(int kk=0;kk<cnt;kk++)
{
//Print message
cout<<setw(20)<<"NAME: "<<employees[kk].name.first<<" "<<employees[kk].name.last<<endl;
//Print rating
cout<<setw(20)<<"PERFORMANCE RATING: "<<employees[kk].performanceRating<<endl;
//Print p id
cout<<setw(20)<<"P ID: "<<employees[kk].pID<<endl;
//Print department
cout<<setw(20)<<"DEPARTMENT: "<<employees[kk].dept<<endl;
//Print salary
cout<<setw(20)<<"SALARY: "<<employees[kk].salary<<endl;
//Print separator
cout<<"================================================="<<endl;
}
}
//Else
else
{
//Print message
cout<<"File cannot be opened."<<endl;
}
//Return
return 0;
Using Structs within Structs Refer to the Structure on page 624 in the 7th Edition of...
Programming Concepts cin/cout variables/types Functions Reference structs Task Summary: For this first Quest you I have set up a program in Visual Studio that will use operation between fractions. I have written a basic code example that does all the resources that you need to follow. Your job is to complete the exercises presented below in quest2.cpp. For this assignment you will learn and demonstrate how to: Work with functions use Past-by-Value and Past-by-Reference. use structs. use cin to get...
Need this in C
The starter code is long, if you know how to do it in other way
please do.
Do the best you can please.
Here's
the starter code:
//
-----------------------------------------------------------------------
// monsterdb.c
//
-----------------------------------------------------------------------
#include
#include
#include
//
-----------------------------------------------------------------------
// Some defines
#define NAME_MAX 64
#define BUFFER_MAX 256
//
-----------------------------------------------------------------------
// Structs
typedef struct
{
char name[NAME_MAX];
int hp;
int attackPower;
int armor;
} Character;
typedef struct
{
int size;
Character *list;
} CharacterContainer;
//
-----------------------------------------------------------------------
//...
1. Define Structure UNIT as described in the list: ınit char codease complete the question int numberOfCreditHours int semester int numberOfPreReq; pointer to number of pre-requisites eg:like char preRequisite[numberOfPreReq][10]; char* preReq int numberOfPostReq; pointer to number of post-requisites eg:like char postRequisite[numberOfPostReq] [1 0]; char* postReq NOTE: this is a BIG question and has to be asked seperately, answering only one question here. pluginfile.php/94428/mod resource/content/1/lab 6202 %20 %28file %20and%20parsing % 29.pdf Expected C++Skills to finish this activity Simple data types C++...
MUST BE DONE IN C++ .MUST BE DONE IN C++ .MUST BE DONE IN C++
.MUST BE DONE IN C++ .MUST BE DONE IN C++ .MUST BE DONE IN C++
.MUST BE DONE IN C++ .MUST BE DONE IN C++ .MUST BE DONE IN C++
.MUST BE DONE IN C++ .MUST BE DONE IN C++ .MUST BE DONE IN C++
.MUST BE DONE IN C++ .MUST BE DONE IN C++ .MUST BE DONE IN C++
.MUST BE DONE IN C++...
C++ project we need to create a class for Book and Warehouse
using Book.h and Warehouse.h header files given. Then make a main
program using Book and Warehouse to read data from book.dat and
have functions to list and find book by isbn
Objectives: Class Association and operator overloading This project is a continuation from Project 1. The program should accept the same input data file and support the same list and find operations. You will change the implementation of...
C++ code and also provide comments explaining everything Credit Card Debt The True Cost of Paying Minimum Payment Write a C++ program to output the monthly payment schedule for a credit card debt, when each month nothing more is charged to the account but only the minimum payment is paid. The output stops when the balance is fully paid - remaining balance = 0. Input: Data input must be done in a separate function. Input the following: credit card balance,...
Activities Define a struct called Unit containing the following fields I Unit code Unit credit hours Unit semester of study List of prerequisites Number of prerequisites List of post requisites Number of post requisites Inside your main function declare an array of type Unit called units with size 20 elements. This array will contain the information related to all the units in our diploma program. Each of the elements of this array correspond with one our diploma units. II III...
Programming Assignment 1 Data structure Java Implement Shellsort for a linked list, based on a variant of bubble sort. The rather severe constraints imposed by the singly-linked list organization presents special problems for implementing Shellsort. Your task is to overcome these constraints and develop a simple, elegant implementation that does not sacrifice efficiency or waste space. Step 1. First, implement a routine to build a list: read integers from standard input, and build a list node for each item consisting...
Part 1: Implement a singly linked list -------------------------------------- (a) Your job is to implement a generic singly linked list that can hold any data type. The interface has been specified and provided to you in a header file called mylist.h. So your job is to write mylist.c that implements each function whose prototype is included in mylist.h. Specifically, you are asked to write the following functions: struct Node *addFront(struct List *list, void *data) void traverseList(struct List *list, void (*f)(void *))...