You should be comfortable with the content in the modules up to and including the module "Arrays" for this project.
Create a class called consultCo that holds a private class called employee that contains the name, pay rate and social security number of an employee of a consulting firm called consultCo. The consultCo class should also have an array that holds all of the objects of all of the employees in the array. This will be an array of employee objects.
Here is a logical diagram of this array of objects:
You will also need functions to satisfy the following requirements:
Minimum Requirements:
· An add function to hire a new employee. This function should create a new object with the employee information (name, payrate and social security number) and then it should add that new object to the array. You are not required to update an employee’s data if the employee exists. (5 points)
· A report function that will display the name, pay rate and social security number of all employees. (5 points).
· A raise function that will give all employees a 10% raise. (5 points).
· You will also need a main function that creates calls the function(s) you created to meet the requirements of this project (5 points).
Notes:
The Module Lab Activity "Lookup!" can be extremely helpful for this project. Just by following the lab activity (and the video demos if needed), you can make significant progress toward completing this assignment.
Answer
#include"class.h"
int main()
{
bool running = true;
companyCo database;
int choice = 0;
while (running == true)
{
std::cout << "\n1. Add an employee" << std::endl;
std::cout << "\n2. Check database" << std::endl;
std::cout << "\n3. This is a good day... INCREASE ALL SALARIES BY 10%!" << std::endl;
std::cout << "\n4. Exit\n" << std::endl;
std::cin >> choice;
if (choice == 1)
{
std::cout << "Add an employee" << std::endl;
database.addEmployee();
}
else if (choice == 2)
{
std::cout << "Check database" << std::endl;
database.displayData();
}
else if (choice == 3)
{
database.increaseSalary();
}
else
{
std::cout << "Exit" << std::endl;
running = false;
}
}
return 0;
}
#include"class.h"
companyCo::companyCo()
{
//to keep the size of the array small enough for testing purposes...
size = 7;
populated = 0;
}
companyCo::employee::employee()
{
//Default value for all the unpopulated areas within the array
name = "not applicable";
payRate = 0.0;
ssN = 000;
}
void companyCo::addEmployee()
{
employee record;
std::string name;
float payRate;
int ssN;
std::cout << "Please enter the Name: " << std::endl;
std::cin >> name;
std::cout << "Please enter the Payrate: " << std::endl;
std::cin >> payRate;
std::cout << "Please enter the SSN: " << std::endl;
std::cin >> ssN;
record.name = name;
record.payRate = payRate;
record.ssN = ssN;
std::cout << "Record added\n\n\n" << std::endl;
//update table
entries[populated] = record;
populated++;
}
void companyCo::displayData()
{
int limit; //user can specify how much to output
std::cout << "Enter the number of eployees you want to see: " << std::endl;
std::cin >> limit;
for (int i = 0; i<limit; i++)
{
std::cout << entries[i].name << std::endl;
std::cout << entries[i].payRate << std::endl;
std::cout << entries[i].ssN << std::endl;
std::cout << std::endl;
}
}
void companyCo::increaseSalary() //increases salary by 10% however, all new members of the array will have no benefit from this...
{
for (int i = 0; i<size; i++)
{
entries[i].payRate = entries[i].payRate * 1.1;
}
std::cout << "\nSalary increased.\n" << std::endl;
木其工作室
#include<iostream>
#include<sstream>
class companyCo
{
private:
class employee
{
public:
std::string name;
float payRate;
int ssN;
employee();
};
int size;
int populated;
employee entries[7]; //7.. is a magic number
public:
companyCo();
void addEmployee();
void displayData();
void increaseSalary();
};
相关推荐
- Allows for a wide array of objects objects, even particle effects to be simulated in the radar. - Static minimaps, ideal for small static scenes. - Realtime Minimap , ideal for large scenes / Open...
'getArray' returns a array of objects from the selected form $(selector).autoNumeric('getArray'); 'getSettings' returns settings for the selected element $(selector).autoNumeric('getSettings')...
在“Learning-cPP-array-of-objects.zip”这个压缩包中,我们重点探讨的是如何在Visual C++环境下使用C++来创建和操作对象数组。通过分析“Learning c++ array of objects.cpp”这个源代码文件,我们可以深入理解这...
对象数组(Array of Objects) Default Constructors和数组 6.2 new和delete运算符 针对数组的new语意 Placement Operator new的语意 6.3 临时性对象(Temporary Objects) 临时性对象的迷思(神话、传说) 第7章 站...
7. 对象数组(Array of Objects): 在主函数中,定义了一个`STU`类的对象数组,用于存储多个学生的信息。使用循环语句输入学生信息,并调用`init()`函数更新每个学生对象的数据。 8. 排序算法: `sort()`函数是一...
// Pass in an array of values.< Sparkline xss=removed>// Sparkline of dates + values// Pass in an array of objects something likevalues = [ { date : "2014-06-23T00:21:59.271Z" value : 2 } , { date : ...
k最近邻居函数 subject: vantage point object - will consider each attribute present in this object as a featureobjects: array of objects that should all have at least the attributes of subjectoptions: ...
小服务器 直播: : 客户回购: : API回购: : Heroku链接: : 消耗API端点/ api / people 得到 returns a JSON object with key "allPeople":['person ... The key's value is an array of objects - each obj
博士 使用Yeoman,Grunt和Bower验证系统配置 插图: 安装 $ npm install -g rff-doctor 用法 $ rff-doctor 选项 -h , --help 显示命令用法并退出。... // Array of objects. // [{ // name: Name of test
// now you have to pass always an array of objects, where each can contain three properties, // only one of them is required - plugin; // plugin property is a plugin class, imported from wavesurfer.js...
// data can be object or array of objects const data = { name : 'categories' , c1 : { name : 'category1' , active : false } , c2 : { name : 'category2' , active : true , products : { name : '...
csv will be converted to an array of objects representing each line in csv, if `axis` is `col`, csv will be converted to an object, each property representing column in csv- `delimiter` csv delimite
countryTelData.allCountries // has data as array of objects countryTelData.iso2Lookup // has data as a map (object) indexed by iso2 name of the country 包含有关一个国家的电话代码的数据。 它包含有关...
// create local model from array of objects in db var tasks = new DDS ( JSON . parse ( localStorage . getItem ( 'tasks' ) ) || [ ] ) ; // keep db updated when local model changes tasks . on ( 'any' ,...
CSS窃取给定的DOM元素... toJS ( ) : // returns an array of objects containing the styles CSSSteal接受多个DOM元素。 例如: var a = document . querySelector ( '.a-class' ) ;var b = document . querySelector
只对array或array of objects排序。 包括以下排序算法: 冒泡排序 选择排序 插入排序 快速排序 归并排序 壳排序 堆排序 基数排序 用法 var SortAlgorithm = require ( 'sortAlgorithm' ) ; var sort = new Sort...
google-sheets-json 从公共Google表格(电子表格)中获取JSON数据,并以一种易于使用的方式格式化数据。快速开始从npm安装软件包: npm ... // array of objects} ) ;spreadsheet . listWorksheets ( function ( err
一个简单的 JavaScript 库,它封装了 Google Docs JSON API。 套件的一部分(但不依赖于核心 Recline)。 用法 从 API 获取数据: recline.Backend.GDocs.fetch({ ... records: // array of Objects
新星表 ... items : an Array of objects endpoint : a URL to request data from item-source : a Source object, see below columns : an object, keys should be field names on the items, values