Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I pretty sure that the code works, but i cant get it to comply on visual studio code. can someone comply the code and send

I pretty sure that the code works, but i cant get it to comply on visual studio code. can someone comply the code and send a snip it/screenshot of the out put. I know it should look like the output is attached.

/////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once

#include

#include "degree.h"

#include "student.h"

const int numStudents = 5;

class Roster {

public:

Roster();

~Roster();

void add(std::string studentID, std::string firstName, std::string lastName, std::string emailAddress, int age, int daysInCourse1, int daysInCourse2, int daysInCourse3, DegreeProgram degreeProgram);

void remove(std::string studentID);

void printAll();

void printAverageDaysInCourse(std::string studentID);

void printInvalidEmails();

void printByDegreeProgram(DegreeProgram degreeProgram);

int length();

Student* classRosterArray[numStudents];

private:

int lastIndex;

};

/////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include

#include "student.h"

Student::Student(std::string studentID, std::string firstName, std::string lastName,

std::string email, int age, int* numDays, DegreeProgram degreeProgram) {

setStudentID(studentID);

setFirstName(firstName);

setLastName(lastName);

setEmail(email);

setAge(age);

setNumDays(numDays);

setDegreeProgram(degreeProgram);

}

std::string Student::getStudentID() { return studentID; }

std::string Student::getFirstName() { return firstName; }

std::string Student::getLastName() { return lastName; }

std::string Student::getEmail() { return email; }

int Student::getAge() { return age; }

int* Student::getNumDays() { return numDays; }

DegreeProgram Student::getDegreeProgram() { return degreeProgram; }

void Student::setStudentID(std::string studentID) { this->studentID = studentID; }

void Student::setFirstName(std::string firstName) { this->firstName = firstName; }

void Student::setLastName(std::string lastName) { this->lastName = lastName; }

void Student::setEmail(std::string email) { this->email = email; }

void Student::setAge(int age) { this->age = age; }

void Student::setNumDays(int* numDays) {

for (int i = 0; i

this->numDays[i] = numDays[i];

}

}

void Student::setDegreeProgram(DegreeProgram degreeProgram) { this->degreeProgram = degreeProgram; }

void Student::print() {

std::cout

"Last Name: "

"Age: "

getNumDays()[1]

degreeProgramStrings[getDegreeProgram()]

}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#include

#include "roster.h"

Roster::Roster() {

this->lastIndex = -1;

}

Roster::~Roster() {

for (int i = 0; i

delete classRosterArray[i];

}

}

void Roster::add(std::string studentID, std::string firstName, std::string lastName, std::string emailAddress, int age, int daysInCourse1, int daysInCourse2, int daysInCourse3, DegreeProgram degreeProgram) {

int daysArray[] = {daysInCourse1, daysInCourse2, daysInCourse3};

Student* newStudent = new Student(studentID, firstName, lastName, emailAddress, age, daysArray, degreeProgram);

classRosterArray[++lastIndex] = newStudent;

}

void Roster::remove(std::string studentID) {

bool studentRemoved = false;

for (int i = 0; i

if (classRosterArray[i]->getStudentID() == studentID) {

delete classRosterArray[i];

classRosterArray[i] = classRosterArray[lastIndex];

lastIndex--;

studentRemoved = true;

break;

}

}

if (!studentRemoved) {

std::cout

}

}

void Roster::printAll() {

for (int i = 0; i

classRosterArray[i]->print();

}

}

void Roster::printAverageDaysInCourse(std::string studentID) {

for (int i = 0; i

if (classRosterArray[i]->getStudentID() == studentID) {

int* days = classRosterArray[i]->getNumDays();

float average = (days[0] + days[1] + days[2]) / 3.0;

std::cout

break;

}

}

}

void Roster::printInvalidEmails() {

for (int i = 0; i

std::string email = classRosterArray[i]->getEmail();

if (email.find('@') == std::string::npos || email.find('.') == std::string::npos || email.find(' ') != std::string::npos) {

std::cout getStudentID()

}

}

}

void Roster::printByDegreeProgram(DegreeProgram degreeProgram) {

for (int i = 0; i

if (classRosterArray[i]->getDegreeProgram() == degreeProgram) {

classRosterArray[i]->print();

}

}

}

int Roster::length() {

return lastIndex;

}

///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////

#pragma once

#include

#include "degree.h"

class Student {

public:

Student(std::string studentID, std::string firstName, std::string lastName,

std::string email, int age, int* numDays, DegreeProgram degreeProgram);

std::string getStudentID();

std::string getFirstName();

std::string getLastName();

std::string getEmail();

int getAge();

int* getNumDays();

DegreeProgram getDegreeProgram();

void setStudentID(std::string studentID);

void setFirstName(std::string firstName);

void setLastName(std::string lastName);

void setEmail(std::string email);

void setAge(int age);

void setNumDays(int* numDays);

void setDegreeProgram(DegreeProgram degreeProgram);

void print();

void printDaysToComplete();

private:

std::string studentID;

std::string firstName;

std::string lastName;

std::string email;

int age;

int numDays[3];

DegreeProgram degreeProgram;

};

///////////////////////////////////////////////////////////////////////////////////////////////

#include

#include

#include

#include

#include "roster.h"

#include "student.h"

#include "degree.h"

using namespace std;

int main() {

const string studentData[] = {

"A1,John,Smith,John1989@gm ail.com,20,30,35,40,SECURITY",

"A2,Suzan,Erickson,Erickson_1990@gmailcom,19,50,30,40,NETWORK",

"A3,Jack,Napoli,The_lawyer99yahoo.com,19,20,40,33,SOFTWARE",

"..k@comcast.net,22,50,58,40,SECURITY",

"..c@wgu.edu,25,30,35,20,SOFTWARE" };

Roster classRoster;

DegreeProgram myDegree{};

for (int i = 0; i

{

stringstream row(studentData[i]);

string student[9];

for (int i = 0; i

{

getline(row, student[i], ',');

}

if (student[8] == "SECURITY")

{

myDegree = DegreeProgram::SECURITY;

}

if (student[8] == "SOFTWARE")

{

myDegree = DegreeProgram::SOFTWARE;

}

if (student[8] == "NETWORK")

{

myDegree = DegreeProgram::NETWORK;

}

classRoster.add(student[0], student[1], student[2], student[3],stoi(student[4]),

stoi(student[5]),stoi(student[6]), stoi(student[7]), myDegree);

}

cout

cout

cout

cout

cout

cout

classRoster.printAll();

classRoster.printInvalidEmails();

for (int i = 0; i

string studentID = classRoster.classRosterArray[i]->getStudentID();

classRoster.printAverageDaysInCourse(studentID);

}

classRoster.printByDegreeProgram(SOFTWARE);

classRoster.remove("A3");

classRoster.printAll();

classRoster.remove("A3");

return 0;

}

//////////////////////////////////////////////////////////////////////////////////

#ifndef DEGREE_H

#define DEGREE_H

enum DegreeProgram { SECURITY, NETWORK, SOFTWARE };

const std::string degreeProgramStrings[] = {

"Security",

"Network",

"Software",

};

#endif

//////////////////////////////////////////////////////////////////////

image text in transcribed
Application: Student Roster Database Mock: : JYM1 TASK 1: CLASS ROSTER Course Title: Scripting and Programming - Applications - C867 Programming Language: C++ Student ID: 010412776 Name: Thomas Ritchie A1 First Name: John Last Name: Smith Email: John1989@gm ail. com Age: 20 days InCourse: {30, 35, 40} Degree Program: Security A2 First Name: Suzan Last Name: Erickson Email: Erickson_1990@gmailcom Age : 19 days InCourse: {50, 30, 40} Degree Program: Network A3 First Name: Jack Last Name: Napoli Email: The_lawyer99yahoo . com Age : 19 days InCourse: {20, 40, 33} Degree Program: Software A4 First Name: Erin Last Name: Black Email: Erin. black@comcast . net Age: 22 days InCourse: {50, 58, 40} Degree Program: Security A5 First Name: Thomas Last Name: Ritchie Email: Trito@wgu. edu Age: 25 days InCourse: {30, 35, 20} Degree Program: Software Invalid email for student A1: John1989@gm ail. com Invalid email for student A2: Erickson_1990@gmailcom Invalid email for student A3: The_lawyer99yahoo. com Average number of days for student A1: 35 Average number of days for student A2: 40 Average number of days for student A3: 31 Average number of days for student A4: 49.3333 A3 First Name: Jack Last Name: Napoli Email: The_lawyer99yahoo . com Age: 19 days InCourse: {20, 40, 33} Degree Program: Software A5 First Name: Thomas Last Name: Ritchie Email: Tritc@wgu. edu Age: 25 days InCourse: {30, 35, 20} Degree Program: Software A1 First Name: John Last Name: Smith Email: John1989@gm ail. com Age: 20 daysInCourse: {30, 35, 40} Degree Program: Security A2 First Name: Suzan Last Name: Erickson Email: Erickson_1990@gmailcom Age : 19 days InCourse: {50, 30, 40} Degree Program: Network A5 First Name: Thomas Last Name: Ritchie Email: Tritc@wgu. edu Age: 25 days InCourse: {30, 35, 20} Degree Program: Software A4 First Name: Erin Last Name: Black Email: Erin. black@comcast . net Age: 22 daysInCourse: {50, 58, 40} Degree Program: Security Error: Student with ID A3 not found

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions