Into to C++ Programming Class Program Problem

Write a class name StudentRecord with the following specifications –
• Data members:
name, marks[ ], major, term (use appropriate data type)
• Member functions:
- You are allowed to leave the constructor default
- Implement all get/set methods
- double findAverage( ) – returns the average mark of the student
- void displayProfile( ) – displays the profile of a student in following manner
Name: John Smith
Major: Computer Science
Term: Fall 2015
Term average: 90%
- Hint: Use getline function to include space
• Main function:
- Take input from user for name, major and term name
- Take input from the user for 5 courses s/he has enrolled in this term (you must put a
validation checking that the range of input such that 100<=marks>=0)
- Create an object of StudentRecord class
- Set name, major, term name and the marks[]
- Invoke displayProfile() function to display the information of the student
Last edited on
We are not a code writing service. If you want to learn programming, make a plan and start writing some code and if you get stuck you can get help.

If you don't want to learn better go to:
https://www.assignmentexpert.com/blog/do-my-c-homework/
http://www.tutorsonnet.com/c++-programming-homework-help.php
This is the code I have written so far:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
#include <iostream>
using namespace std;

//defining a class name StudentRecord

class StudentRecord{

	//defining the characteristics of StudentRecord
	//Data members
	string name;
	int marks[];
	string major;
	string term;

	//defining the function of StudentRecord
	//Member functions

	public:
		StudentRecord();
		void setName(string name);
		void setMarks(int marks);
		void setMajor(string major);
		void setTerm(string term);
		string getName();
		int getMarks();
		string getMajor();
		string getTerm();
		double findAverage();
		void displayProfile();
};

//Implementation of the functions
	
	//default constructor
	StudentRecord::StudentRecord(){
		cout << "constructor" << endl;
	}

	//defining mutators

	string StudentRecord::getName(){
		return name;
	}

	int StudentRecord::getMarks(){
		return marks;
	}

	string StudentRecord::getTerm(){
		return term;
	}

	//defining accesors

	void StudentRecord::setName(string name){
		
	}

	void StudentRecord::setMarks(int marks){
	
	}

	void StudentRecord::setMajor(string major){
		
	}

	void StudentRecord::setTerm(string term){
		
	}

	void StudentRecord::setdisplayProfile(){

	}

	//member function
	double StudentRecord::findAverage(){
		return 0.0;
	}


int main(){
	
	//taking input from user for name, major and term name
	int name, major, termname

	cout << "Please enter name: ";
	cin >> name;

	cout << "Please enter major: ";
	cin >> major;

	cout << "Please enter term name: ";
	cin >> termname;

	//taking input from user for 5 courses she/he has enroled in this term
	int course1, course2, course3, course4, course5;
	
	cout << "Please enter 1st course enrolled in: ";
	cin >> course1;
	
	cout << "Please enter 2nd course enrolled in: ";
	cin >> course2;

	cout << "Please enter 3rd course enrolled in: ";
	cin >> course3;

	cout << "Please enter 4th course enrolled in: ";
	cin >> course4;

	cout << "Please enter 5th course enrolled in: ";
	cin >> course5;
	//validation checking that the range of input such that 100<=marks>=0?

	//creating object of StudentRecord class?

	//setting name, major, term name and the marks[]?

	//invoking displayProfile() function to display the information of the student?

	return 0;
}
On line 11 you cannot specify an array without size. int marks[];
Since you have to take the input from 5 courses you better write it like this.
1
2
const int NUM_COURSES = 5; // outside your class
int marks[NUM_COURSES]; // line 11 


If you get any more error messages please paste all the messages here.
updated written code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
#include <iostream>
using namespace std;

const int NUM_COURSES = 5;

//defining a class name StudentRecord

class StudentRecord{

	//defining the characteristics of StudentRecord
	//Data members
	string name;
	double marks[NUM_COURSES];
	string major;
	string term;

	//defining the function of StudentRecord
	//Member functions

	public:
		StudentRecord(); //default constructor
		void setName(string name);
		void setMarks(double marks[NUM_COURSES]);
		void setMajor(string major);
		void setTerm(string term);
		string getName();
		double getMarks();
		string getMajor();
		string getTerm();
		double findAverage();
		void displayProfile();

	~StudentRecord(){
		cout << "destructor" << endl;
	}
};

//Implementation of the functions
	
	//default constructor
	StudentRecord::StudentRecord(){
		cout << "constructor" << endl;
	}

	//defining mutators

	string StudentRecord::getName(){
		return name;
	}

	double StudentRecord::getMarks(){
		return marks[NUM_COURSES];
	}

	string StudentRecord::getMajor(){
		return major;
	}

	string StudentRecord::getTerm(){
		return term;
	}

	double StudentRecord::findAverage(){
		return 0.0;
	}

	//defining accesors

	void StudentRecord::setName(string n){
		name = n;
	}

	void StudentRecord::setMarks(double m){
		marks[NUM_COURSES] = m;
	}

	void StudentRecord::setMajor(string maj){
		major = maj;
	}

	void StudentRecord::setTerm(string t){
		term = t;
	}


int main(){
	
	//taking input from user for name, major and term name
	string name, major, term;

	cout << "Please enter name: ";
	cin >> name;

	cout << "Please enter major: ";
	cin >> major;

	cout << "Please enter term name: ";
	cin >> term;

	//taking input from user for marks for 5 courses she/he has enroled in this term marks
	int course1, course2, course3, course4, course5;
	
	cout << "Please enter 1st enrolled in course mark: ";
	cin >> course1;
	
	cout << "Please enter 2nd enrolled in course mark: ";
	cin >> course2;

	cout << "Please enter 3rd enrolled in course mark: ";
	cin >> course3;

	cout << "Please enter 4th enrolled in course mark: ";
	cin >> course4;

	cout << "Please enter 5th enrolled in course: ";
	cin >> course5;
	//validation checking that the range of input such that 100<=marks>=0?

	//creating object of StudentRecord class?

	//setting name, major, term name and the marks[]?

	//invoking displayProfile() function to display the information of the student?

	return 0;
}

Please, check for errors and give me suggestions on how to do the stuff I haven't written code for in the main function.
Topic archived. No new replies allowed.