Write a class name StudentRecord with the following specific

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% 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=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 Special instruction: You MUST submit following 3 files - StudentProfile.h StudentProfile.cpp StudentProfileMain.cpp

Solution

// StudentRecord.h
#ifndef StudentRecord_H
#define StudentRecord_H

class StudentRecord
{
string name;
double marks[5];
string major;
string term;

public:
StudentRecord();
void setName(string studName);
void setMarks(double studMarks[]);
void setMajor(string tempMajor);
void setTerm(string tempTerm);
string getName();
double[] getMarks();
string getMajor();
string getTerm();
double findAverage();
void displayProfile();
};
#endif

--------------------------------------------------------------------------
// StudentRecord.cpp
#include \"StudentRecord.h\"

//empty constructor
StudentRecord::StudentRecord(){
}

//setter methods
void StudentRecord::setName(string studName){
   this.name = studName;
}
void StudentRecord::setMarks(double studMarks[]){
   this.marks = studMarks;
}
void StudentRecord::setMajor(string tempMajor){
   this.major = tempMajor;
}
void StudentRecord::setTerm(string tempTerm){
   this.term = tempTerm;
}

//getter methods
string StudentRecord::getMajor(){
`   return major;
}
string StudentRecord::getTerm(){
`   return term;
}
string StudentRecord::getName(){
`   return name;
}
double[] StudentRecord::getMarks(){
`   return marks;
}

//finding average
doueble StudentRecord::findAverage(){
   double sum = 0;
   for(int i=0;i<5;i++){
       sum = sum + marks[i];
   }
   return sum/marks.length;
}

// method to display profile
void StudentRecord::displayProfile(){
   cout<<\"\ Name: \"<<name;
   cout<<\"\ Major: \"<<major;
   cout<<\"\ Term: \"<<term;
   cout<<\"\ Team Average: \"<<findAverage();
}

//main
#include <iostream>
using namespace std;
int main(){
   string name, major,term;
   double marks[5];
   //reading data
   cout<<\"Enter name: \";
   cin>>name;
   cout<<\"Enter term: \";
   cin>>term;
   cout<<\"Enter major: \";
   cin>>major;
   cout<<\"Enter your 5 course marks: \";
   for(int i=0;i<5;i++){
       double score;
       cin>>score;
       if(score > 100 || score < 0){
           marks[i] = 0;
       }
       else{
           marks[i] = score;
       }
   }
  
   //creating student record object
   StudentRecord obj;
   //calling methods
   obj.setName(name);
   obj.setTerm(term);
   obj.setMajor(major);
   obj.setMarks(marks);
   obj.displayProfile();
   return 0;
}

 Write a class name StudentRecord with the following specifications - Data members: name, marks[], major, term (use appropriate data type) Member functions: You
 Write a class name StudentRecord with the following specifications - Data members: name, marks[], major, term (use appropriate data type) Member functions: You
 Write a class name StudentRecord with the following specifications - Data members: name, marks[], major, term (use appropriate data type) Member functions: You

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site