Structured Data and Abstract Data Types Lab

Your Mission: Write a program that uses a structure to store the following data for each month:

Member Name
Description
name employee name
age employee age
salary employee salary

The program should create an array of 5 structures to hold employee data. When the program runs, it should ask the user to enter data for each employee. Once the data are entered for all employees, the program should display the employee records, the highest and lowest paid employees, and the total annual payroll.

Algorithmic suggestion: You can use this if you wish or go it alone.

// Written by: Date:
//
// Description: Describe the input, processing, and output

#include <iostream>
#include <string>
using namespace std;

//define structure
struct Employee
{
string name;
int age;
double salary;
};

void displayData(Employee); // Function prototype

const int SIZE = 5;

int main() {

Employee emp[SIZE];
int high = 0, low = 0;

//get employee info
for (int i = 0; i < SIZE; i++)
{
//input code to get employee information for all employees
}

// Function call with structure variable as an argument
for (int i = 0; i < SIZE; i++)
{
//input code to call displayData with a single employee record
}

//determine highest and lowest paid
//set high and low equal to the first element in array

for (int i = 0; i < SIZE; i++)
{
//search emp array for high and low salary
}

//output high/low salary employees and total payroll


return 0;
}

//function to display the employee records. Receives a single employee structure and outputs the fields.
void displayData(Employee emp)
{
//input code to display an individual employee record
}

Back to Top

! You are using a version 4 browser or older. If you are experiencing any problems with scrolling, please reload the page.