Complete Course.cpp by implementing the PrintRoster() function, which outputs a list of all students enrolled in a course and also the total number of students in the course.
Given files:
main.cpp - contains the main function for testing the program.
Course.cpp - represents a course, which contains a vector of Student objects as a course roster. (Type your code in here)
Course.h - header file for the Course class.
Student.cpp - represents a classroom student, which has three data members: first name, last name, and GPA.
Student.h - header file for the Student class.
Ex: If the program has 4 students enrolled in the course, the output looks like:
Henry Cabot (GPA: 3.5) Brenda Stern (GPA: 2.1) Jane Flynn (GPA: 3.9) Lynda Robison (GPA: 3.2) Students: 4
Course.cpp #include "Course.h" #include "Student.h" using namespace std; // TODO: Output each student in the course roster, and then the total size of the course } void Course::AddStudent(Student s) { roster.push_back(s); } Course.h #ifndef COURSE_H_ #define COURSE_H_ #include <iostream> #include <vector> #include "Student.h" using namespace std; class Course { public: void PrintRoster(); // string GetCode(); void AddStudent(Student); private: vector<Student> roster; }; #endif /* COURSE_H_ */ Main.cpp #include <iostream> #include "Course.h" #include "Student.h" using namespace std; int main() { Course course = Course(); course.AddStudent(Student("Henry", "Cabot", 3.5)); course.AddStudent(Student("Brenda", "Stern", 2.1)); course.AddStudent(Student("Jane", "Flynn", 3.9)); course.AddStudent(Student("Lynda", "Robison", 3.2)); course.PrintRoster(); return 0; } Student.h #ifndef STUDENT_H_ #define STUDENT_H_ #include <iostream> using namespace std; class Student { public: Student(string, string, double); double GetGPA(); string GetFirst(); string GetLast(); private: string first; string last; double gpa; }; #endif /* STUDENT_H_ */ Student.cpp #include "Student.h" using namespace std; Student::Student(string f, string l, double g) { first = f; // first name last = l; // last name gpa = g; // grade point average } double Student::GetGPA() { return gpa; } string Student::GetFirst() { return first; } string Student::GetLast() { return last; }
void Course::PrintRoster(){
//traverse the roster vector
for(auto i = roster.begin(); i != roster.end(); i++){
//print firstname, lastname and grade of students
cout<<i->GetFirst()<<" "<<i->GetLast()<<" (GPA: "<<i->GetGPA()<<")"<<endl;
}
//print the total no. of students
cout<<"Students: "<<roster.size()<<endl;
}
#include<iostream>
#include<vector>
using namespace std;
//Student class defination
class Student{
string first;
string last;
double gpa;
public:
Student(string, string, double);
double GetGPA();
string GetFirst();
string GetLast();
};
//Course class defination
class Course{
vector<Student> roster;
public:
void AddStudent(Student);
void PrintRoster();
};
//Student class constructor
Student::Student(string f, string l, double g){
first = f;
last = l;
gpa = g;
}
//getters for Student class
string Student::GetFirst(){
return first;
}
string Student::GetLast(){
return last;
}
double Student::GetGPA(){
return gpa;
}
//Course function for adding students to roster
void Course::AddStudent(Student s){
roster.push_back(s);
}
//print roster
void Course::PrintRoster(){
//traverse the roster vector
for(auto i = roster.begin(); i != roster.end(); i++){
//print firstname, lastname and grade of students
cout<<i->GetFirst()<<" "<<i->GetLast()<<" (GPA: "<<i->GetGPA()<<")"<<endl;
}
//print the total no. of students
cout<<"Students: "<<roster.size()<<endl;
}
//main function
int main(){
Course course = Course();
course.AddStudent(Student("Henry", "Cabot", 3.5));
course.AddStudent(Student("Brenda", "Stern", 2.1));
course.AddStudent(Student("Jane", "Flynn", 3.9));
course.AddStudent(Student("Linda", "Robinson", 3.2));
course.PrintRoster();
return 0;
}
Complete Course.cpp by implementing the PrintRoster() function, which outputs a list of all students enrolled in a course and also the total number of students in the course.
Given a class called Student and a class called Course that contains an ArrayList of Student. Write a method called getDeansList() as described below. Refer to Student.java below to learn what methods are available. I will paste both of the simple .JAVA codes below COURSE.JAVA import java.util.*; import java.io.*; /****************************************************** * A list of students in a course *****************************************************/ public class Course{ /** collection of Students */ private ArrayList<Student> roster; /***************************************************** Constructor for objects of class Course *****************************************************/...
This is a simple C++ class using inheritance, I have trouble getting the program to work. I would also like to add ENUM function to the class TeachingAssistant(Derived class) which is a subclass of Student(Derived Class) which is also a subclass of CourseMember(Base Class). The TeachingAssistant class uses an enum (a user-defined data type) to keep track of the specific role the TA has: enum ta_role {LAB_ASSISTANT, LECTURE_ASSISTANT, BOTH}; You may assume for initialization purposes that the default role is...
Files given in this assignment (right-click on the file to download) Assignment7.cpp (need to complete) Student.h (Given. Just use it, don't change it!) Student.cpp (Partially filled, need to complete) 1. Assignment description In this assignment, you will write a simple class roster management system for ASU CSE100. Step #1: First, you will need to finish the design of class Student. See the following UML diagram for Student class, the relevant header file (class declaration) is given to you as Student.h,...
Use C++! This program uses the class myStack to determine the highest GPA from a list of students with their GPA.The program also outputs the names of the students who received the highest GPA. Redo this program so that it uses the STL list and STL queue! Thank you! HighestGPAData.txt* 3.4 Randy 3.2 Kathy 2.5 Colt 3.4 Tom 3.8 Ron 3.8 Mickey 3.6 Peter 3.5 Donald 3.8 Cindy 3.7 Dome 3.9 Andy 3.8 Fox 3.9 Minnie 2.7 Gilda 3.9 Vinay...
Rework this project to include a class. As explained in class, your project should have its functionalities moved to a class, and then create each course as an object to a class that inherits all the different functionalities of the class. You createclass function should be used as a constructor that takes in the name of the file containing the student list. (This way different objects are created with different class list files.) Here is the code I need you...