Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In C++: Write a program that allows the user to initially enter information on 4 students and 10 courses. Have the program associate each student

In C++: Write a program that allows the user to initially enter information on 4 students and 10 courses. Have the program associate each student with at least four courses for a semester session. The program will display a report showing the assigned courses for each student with the total number of credits.

The student information should include:

1. student ID

2. first name

3. last name

The course information should include:

1. Course ID

2. Course name

3. Number of credits

Design requirement:

A student will be assigned a course through a session. The session should include the following attributes:

1. session ID

2. student ID

3. course ID

4. start date

5. end date

______________________________________________________________________________

# Here's what I have so far...

//student.h

#include

using namespace std;

#ifndef STUDENT_H

#define STUDENT_H

class Student

{

public:

//constructors for student

/**

Student has first name, last name, and student ID

*/

Student();

Student(string, string, int);

//mutators

void values(string, string, int);

void setFName(string);

void setLName(string);

void setID(int);

//Accessors

string getFName();

string getLName();

int getID();

string FName;

string LName;

int ID;

};

#endif

//student.cpp

#include

using namespace std;

#include "Student.h"

//constructor definition

Student::Student() {

values ("Your", "Name", 11111);

}

Student::Student(string f, string l, int i) {

values(f, l, i);

}

void Student::values(string f, string l, int i) {

FName = f;

LName = l;

ID = i;

}

void Student::setFName(string f)

{

FName = f;

}

void Student::setLName(string l)

{

LName = l;

}

void Student::setID(int i)

{

ID = i;

}

string Student::getFName()

{

return FName;

}

string Student::getLName()

{

return LName;

}

int Student::getID()

{

return ID;

}

//course.h

#include

using namespace std;

#ifndef COURSE_H

#define COURSE_H

class Course

{

public:

// constructors

// it has courseName, courseID, and Number of credits.

Course();

Course(string, int, int);

//mutators

void values(string, int, int);

void setCourseName(string);

void setCourseID(int);

void setNumOfCredits(int);

// Accessors

string getCourseName();

int getCourseID();

int getNumOfCredits();

string CourseName;

int CourseID;

int NumOfCredits;

};

#endif

//course.cpp

#include

using namespace std;

#include"Course.h"

// construction definition

Course::Course() {

values("Data Structures", 12345, 54321);

}

Course::Course(string c, int i, int n) {

values(c, i, n);

}

void Course::values(string c, int i, int n) {

CourseName = c;

CourseID = i;

NumOfCredits = n;

}

void Course::setCourseName(string c) {

CourseName = c;

}

void Course::setCourseID(int i) {

CourseID = i;

}

void Course::setNumOfCredits(int n) {

NumOfCredits = n;

}

string Course::getCourseName() {

return CourseName;

}

int Course::getCourseID() {

return CourseID;

}

int Course::getNumOfCredits() {

return NumOfCredits;

}

*There are errors on this code. Session contains foreign keys (CourseID and StudentID) from Student and Course class.

//session.h

#include

#include

#include "Student.h"

#include "Course.h"

using namespace std;

#ifndef SESSION_H

#define SESSION_H

class Session

{

public:

Session();

Session(int, int, string, string, Student*, Course*);

void values(int, string, string, Student*, Course*);

void setSessionID(int);

void setStartDate(string);

void setEndDate(string);

void settotalCredit(int);

//void setCourseID();

//void setID();

int getSessionID();

string getStartDate();

string getEndDate();

int gettotalCredit();

//int getCourseID();

//int getID();

int SessionID;

string startDate;

string endDate;

int totalCredit;

Student* sPTR; // reference to student

Course* cPTR; // reference to course

};

#endif

There are lots of errors here, please Help. Can you also run the program and screenshot the result.

//session.cpp

#include

#include

using namespace std;

#include "Student.h"

#include "Course.h"

#include "Session.h"

/*

Session::Session(int id, string sD, string eD, Student* sPTR s, Course* cPTR c) {

SessionID = id;

startDate = sD;

endDate = eD;

sPTR = s;

cPTR = c;

}

*/

void fillStudents(Student arg[], int size)

{

for (int i = 0; i < size; i++)

{

cout <<"Student #"<

cout <<"=========="<

cout <<"Enter a student ID: ";

cin >>arg[i].ID;

cout <<"Enter the first name: ";

cin >>arg[i].FName;

cout <<"Enter the last name: ";

cin >>arg[i].LName;system("CLS");

}

}

void fillCourse(Course cu[], int size) {

for (int i = 0; i < size; i++) {

cout <<"Course #"<

cout <<"============"<

cout <<"Enter a Course ID: ";

cin >>cu[i].CourseID;

cout <<"Enter the course Name: ";

cin >>cu[i].CourseName;

cout <<"Enter the Number of credits: ";

cin >>cu[i].NumOfCredits;system("CLS");

}

}

string CourseN(int choice, Course ch[])

{

switch(choice) {

case 1:

return ch[0].CourseID+" "+ch[0].CourseName;

break;

case 2:

return ch[1].CourseID+" "+ch[1].CourseName;

break;

case 3:

return ch[2].CourseID+" "+ch[2].CourseName;

break;

case 4:

return ch[3].CourseID+" "+ch[3].CourseName;

break;

case 5:

return ch[4].CourseID+" "+ch[4].CourseName;

break;

case 6:

return ch[5].CourseID+" "+ch[5].CourseName;

break;

case 7:

return ch[6].CourseID+" "+ch[6].CourseName;

break;

case 8:

return ch[7].CourseID+" "+ch[7].CourseName;

break;

case 9:

return ch[8].CourseID+" "+ch[8].CourseName;

break;

case 10:

return ch[9].CourseID+" "+ch[9].CourseName;

break;

// program will close if inapporiate choices are entered as an input.

default:

cout<<"Inappropriate Choice!" <

exit(0);

}

}

int creditTotal(int sel, Course ch[]) {

switch(sel)

{

case 1:

return ch[0].NumOfCredits;

break;

case 2:

return ch[1].NumOfCredits;

break;

case 3:

return ch[2].NumOfCredits;

break;

case 4:

return ch[3].NumOfCredits;

break;

case 5:

return ch[4].NumOfCredits;

break;

case 6:

return ch[5].NumOfCredits;

break;

case 7:

return ch[6].NumOfCredits;

break;

case 8:

return ch[7].NumOfCredits;

break;

case 9:

return ch[8].NumOfCredits;

break;

case 10:

return ch[9].NumOfCredits;

break;

default:

cout<<"Invalid input!"<

exit(0);

}

}

void fillSession(Student arg[], Course cu[], Session se[]) {

int course1, course2, course3, course4;

string ch1, ch2, ch3, ch4;

string startDate, endDate;

int credit1, credit2, credit3, credit4;

for (int i = 0; i < 4; i++) {

for (int j = 0; j , 10; j++) {

cout<<"Class #"<

<

}

cout<<"Enter your first class choice: ";

cin>>course1;

ch1=CourseN(course1,cu);

cout<<"Enter your second class choice: ";

cin>>course2;

ch2=CourseN(course2, cu);

cout<<"Enter your third class choice: ";

cin>>course3;

ch3=CourseN(course3, cu);

cout<<"Enter your fourth class choice: ";

cin>>course4;

ch4=CourseN(course4, cu);

/*

se[i].CourseID=ch1+" "+ch2" "+ch3" "+ch4;

cout<<"Enter the start date of your classes in format(mm/dd/yyyy): ";

cin>>startDate;

se[i].startDate=startDate;

cout<<"Enter the end date of your class in format(mm/dd/yyyy): ";

cin>> endDate;

se[i].endDate=endDate;

*/

credit1=creditTotal(course1, cu);

credit2=creditTotal(course2, cu);

credit3=creditTotal(course3, cu);

credit4=creditTotal(course4, cu);

se[i].totalCredit=credit1+credit2+credit3+credit4;

course1=0;

course2=0;

course3=0;

course4=0;

system("clear");

}

}

void displayReport(Student s[], Course c[], Session Se[])

{

for (int i = 0; i < 4; i++) {

cout<<"Student ID: "<

cout<<"Student Name: "<

cout<<"Course IDs: "<

cout<<"Start Date: "<

cout<<"End date: "<

cout<<"Total Credits: "<

cout<<" "<

}

}

int main(void)

{

//declare and initialize 5 students

Student stu[5];

fillStudents(stu, 5);

//declare and initialize 10 courses

Course cs[10];

fillCourse(cs, 10);

Session se[4];

fillSessions(Student, Course, Session);

cout<<"++++++++++++++++++++++++++++++++++++"<

displayReport(Student, Course, Session);

cin.get();

system("PAUSE");

return 0;

}

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

More Books

Students also viewed these Databases questions

Question

=+Are you interested in working on global teams?

Answered: 1 week ago

Question

=+Do you want to work from home?

Answered: 1 week ago

Question

=+ What skills and competencies will enable someone

Answered: 1 week ago