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
Can someone check my coding and let me know of any errors? This is what I have 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
|
#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:
//function prototypes
StudentRecord();
void setName();
void setMarks(int mark);
void setMajor();
void setTerm();
string getName();
int getMarks();
string getMajor();
string getTerm();
double findAverage();
double findAverage(){
}
void displayProfile(name, major, term, termAverage);
};
StudentRecord::StudentRecord(){
name = "John Smith";
major = "Computer Science";
term = "Fall 2015"
term average = 90
}
string StudentRecord::getName(){
return name;
}
string StudentRecord::getMarks(){
return marks;
}
string StudentRecord::getTerm(){
return term;
}
double StudentRecord::findAverage(){
return 0.0;
}
void StudentRecord::setName(string nm){
Name = nm;
}
void StudentRecord::setMajor(string mj){
Major = mj;
}
void StudentRecord::setTerm(string trm){
Term = trm;
}
void StudentRecord::setMarks(int mark){
Marks = mark;
}
void StudentRecord::setdisplayProfile(){
}
int main(){
StudentRecord myProfile;
string findName = myProfile.getName();
cout<< findName << endl;
string findMajor = myProfile.getMajor();
cout << findMajor <<endl;
string findTerm = myProfile.getTerm();
cout << findTerm << endl;
}
|