Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need help creating a program that generates end year bonuses for a company bas

ID: 3909996 • Letter: I

Question

I need help creating a program that generates end year bonuses for a company based on each employee. The directions are below:

The data is read in by data.txt will contain 5000 lines so I'm not going to include a sample of the entire file but here are a couple lines of how it should look:

data.txt - sample output

Obiectives: The software testing process (i.e., the BBT) consumes large amounts of data. Creating the test data is a crucial part of the testing process especially for new systems which are not in use yet. This assignment will give you an opportunity to practice creating representative test data. After completing this assignment, students will be able to: Create random data from a given set of parameters Create a large number of test cases to test all possibilities Write a C++ program to process . . the data as though it were collected from a real situation. This assignment will be submitted into two parts (Part-A and Par-B) - a separate Code::Blocks project is required for each part. Problem description: A large company that sells high end furniture needs a program to help calculate their year end bonuses. For each of their 5000 employees, a percentage of their total sales amount minus the minimum total sales amount (taken from the employee with the lowest number of furniture sales) is multiplied by a percentage of their salary. This is their year end bonus, and employees count on this to be calculated accurately, since it can easily double their salary if they have a high sale volume Part- Write a C++ program to generate the data file "data.txt". Each line in this file represents an employee record, with each element separated by a comma which includes the empID, firstname, lastname, storeID, salary, daysWorked As shown below for one employee: 100002, ozyomoimmtplme, tpvcrdfrowjnfur, 3549, 44442, 225, The record above is just an example of one employee, remember there are 5000 employees. The text file should be sorted with the lowest empID first. Use an array of struct for the creation of the employees. Please note that the empID is a unique 6 digit number. You should use a random number generator to generate a unique ID for each employee. This should be accomplished within a stand alone function called genIDO which also checks to make sure the ID is unique within the array of 5000 function accesses the entire array is part of why it is a standalone function and not a member function of the struct employee. For each employee you must randomly generate: employees. The fact that this A unique empID of 6 digits. A first name and a last name, (not unique) of random length between 8 and 16 characters, made up of random chars. This can be stored in separa te variables or within its own struct

Explanation / Answer

#include <string>
#include <stdlib.h>
#include <iostream>
#include <fstream>
#include <time.h>
#include <array>
#include <vector>
#include <algorithm>

using namespace std;

const int MAX_EMPLOYEES = 10;
static vector<int> generatedIds;

struct Employee {
long empID;
string firstName;
string lastName;
int storeId;
int salary;
int daysWorked[12];
int monthlySalesTotal[12] = { 0 };

Employee() {};

Employee(long id, string fname, string lname, int store, int sal)
{
empID = id;
firstName = fname;
lastName = lname;
storeId = store;
salary = sal;
}

bool CompareTo(const Employee& other) {
return this->empID > other.empID;
}

void Print(ofstream& os)
{
int totalDays = 0;
string totalSales = "";
for (int i = 0; i < 12; i++)
{
totalDays += daysWorked[i];
totalSales += " " + to_string(monthlySalesTotal[i]);
}
os << empID << ", " << firstName << ", " << lastName << ", " << storeId << ", " << salary << ", " << totalDays << "," << totalSales;
}
};

int genRand(int min, int max)
{
return rand() % max + min;
}

int genID(const array<Employee, MAX_EMPLOYEES>& employees)
{
int id = genRand(100000, 999999);
if (employees.empty())
return id;
for (const auto& emp : employees) {
if (emp.empID == id)
genID(employees);
}

return id;
}

string genRandName()
{
// Generate random name and return
return string();
}

void SortEmployees(array <Employee, MAX_EMPLOYEES>& employees)
{
for (int i = 0; i < MAX_EMPLOYEES - 1; i++)
{
for (int j = 0; j < MAX_EMPLOYEES; j++)
{
if (employees[j].CompareTo(employees[i]))
{
Employee tmp = employees[j];
employees[j] = employees[i];
employees[i] = tmp;
}
}
}
}
int main()
{
srand(time(0));
array<Employee, MAX_EMPLOYEES> employees;

for (size_t i = 0; i < MAX_EMPLOYEES; ++i)
{
employees[i] = Employee(genID(employees), string(), string(), genRand(1000, 9999), genRand(20000, 100000));
for (int j = 0; j < 12; j++)
{
employees[i].daysWorked[j] = genRand(0, 21);
for (int k = 0; k < employees[i].daysWorked[j]; k++)
{
int daySale = employees[i].salary < 60000 ? genRand(1000, 15000) : genRand(3000, 20000);
employees[i].monthlySalesTotal[j] += daySale;
}
}
}

SortEmployees(employees);
ofstream outFile("data.txt");
for (auto& emp : employees)
{
emp.Print(outFile);
outFile << endl;
}
outFile.close();
return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote