Question

COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see...

COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see which professor has the highest rating according to student input. You will create a ProfessorRating class consisting of professor Name and three ratings. The three ratings are used to evaluate easiness, helpfulness, and clarity. The value for each rating is in the range of 1 to 5, with 1 being the lowest and 5 being the highest. Your program should contain the following functionalities: a. Create a class named ProfessorRating with 4 data members: profName with string type and easiness, helpfulness, and clarity with int type b. Your class should contain the following methods: a. default constructor which initializes the private data members b. initialization constructor which passes four parameters and sets the value for each data member c. a copy constructor: ProfessorRating(const ProfessorRating &profRating) d. a destructor e. a getter (accessor) method for each data member. f. double calcRating() const – returns the average rating ((easiness+helpfulness+clarity)/3.0) g. void print() const– displays the professor name and his/her three ratings and the average rating. h. void setData(string name, int easy, int help, int clari) – assigns parameter values to each private data member. i. An overloaded operator function (==) bool operator == (const ProfessorRating &) – Checks if two professors have the same ratings for easiness, helpfulness and clarity. c. Create your class in a header file (ProfessorRating.h) with the above structures. Create an implementation file (ProfessorRating.cpp) to implement all the methods in your class. Test your class with user interface in your main program. (** make sure to include your class header file in your main program) #include “ProfessorRating.h” d. In your main program, create an array of ProfessorRating which holds a list of 3 professor ratings. You can make your own test data (professor info). const int SIZE=3; ProfessorRating csProfs[SIZE]; e. Create a function to fill the array with professor names and each rating. void fillProfList(ProfessorRating profList[]) f. Create a generic function to get each rating int getRating(string ratingType), where ratingType is passed into the function to indicate either “Easiness”, “Helpfulness”, or “Clarity” that you like to prompt to the user so they can enter proper rating. You will call this function 3 times to get each rating. You need to validate the rating to make sure it is between 1 and 5. g. Create a function to locate the professor with the highest average rating and display the name and rating. void displayHighestRating(ProfessorRating profList[]) h. Display the output for all professors’ names, ratings and average ratings. Display the professor with the highest average rating. You can design your own output. Format your output with two decimal places. Submit header file (.h file), implementation file (.cpp), test source file (main program), and output screenshot on Canvas for grading.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

// ProfessorRating.h

#ifndef PROFESSORRATING_H_

#define PROFESSORRATING_H_

#include <iostream>

using namespace std;

class ProfessorRating

{

private:

       string name;

       int easiness,helpfulness,clarity ;

public:

       ProfessorRating();

       ProfessorRating(string,int,int,int);

       ProfessorRating(const ProfessorRating &rating);

       ~ProfessorRating();

       string getName() const;

       int getEasiness() const;

       int getHelpfulness() const;

       int getClarity() const;

       double calcRating() const;

       void print() const;

       void setData(string,int,int,int);

       bool operator==(const ProfessorRating &rating) const;

};

#endif /* PROFESSORRATING_H_ */

//end of ProfessorRating.h

// ProfessorRating.cpp

#include "ProfessorRating.h"

#include <iomanip>

ProfessorRating::ProfessorRating() : name(""), easiness(0), helpfulness(0), clarity(0)

{}

ProfessorRating::ProfessorRating(string name, int easiness, int helpfulness, int clarity) : name(name), easiness(easiness),helpfulness(helpfulness),clarity(clarity)

{}

ProfessorRating::ProfessorRating(const ProfessorRating &rating) : name(rating.name), easiness(rating.easiness), helpfulness(rating.helpfulness), clarity(rating.clarity)

{}

ProfessorRating::~ProfessorRating()

{}

string ProfessorRating::getName() const

{

       return name;

}

int ProfessorRating::getEasiness() const

{

       return easiness;

}

int ProfessorRating::getHelpfulness() const

{

       return helpfulness;

}

int ProfessorRating::getClarity() const

{

       return clarity;

}

double ProfessorRating::calcRating() const

{

       return(((double)(easiness+helpfulness+clarity))/3.0);

}

void ProfessorRating::setData(string name, int easiness, int helpfulness, int clarity)

{

       this->name = name;

       this->easiness = easiness;

       this->helpfulness = helpfulness;

       this->clarity = clarity;

}

void ProfessorRating::print() const

{

       cout<<"Name : "<<name<<endl;

       cout<<"Easiness : "<<easiness<<endl;

       cout<<"Helpfulness : "<<helpfulness<<endl;

       cout<<"Clarity : "<<clarity<<endl;

       cout<<"Average Rating : "<<fixed<<setprecision(2)<<calcRating()<<endl<<endl;

}

bool ProfessorRating::operator ==(const ProfessorRating &rating) const

{

       return((easiness == rating.easiness ) && (helpfulness == rating.helpfulness) && (clarity == rating.clarity));

}

//end of ProfessorRating.cpp

// main.cpp : C++ program to test the ProfessorRating class

#include <iostream>

#include "ProfessorRating.h"

#include <limits>

#include <iomanip>

using namespace std;

void fillProfList(ProfessorRating profList[], int size);

int getRating(string ratingType);

void displayHighestRating(ProfessorRating profList[], int size);

int main()

{

       const int SIZE = 3;

       ProfessorRating csProfs[SIZE];

       fillProfList(csProfs,SIZE);

       cout<<"\nDetails of professors : "<<endl;

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

             csProfs[i].print();

       displayHighestRating(csProfs,SIZE);

       return 0;

}

void fillProfList(ProfessorRating profList[], int size)

{

       string name;

       int easiness, helpfulness, clarity;

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

       {

             cout<<"\nEnter the details for professor "<<(i+1)<<" : "<<endl;

             cout<<"Name : ";

             getline(cin,name);

             easiness = getRating("Easiness");

             helpfulness = getRating("Helpfulness");

             clarity = getRating("Clarity");

             profList[i].setData(name,easiness,helpfulness,clarity);

             std::cin.ignore(std::numeric_limits<std::streamsize>::max(),'\n'); //cin leaves \n in the input so remove it

       }

}

int getRating(string ratingType)

{

       int rating;

       cout<<ratingType<<" rating : ";

       cin>>rating;

       while(cin.fail() || rating < 1 || rating > 5)

       {

             std::cin.clear(); // back in 'normal' operation mode

             std::cin.ignore(std::numeric_limits<std::streamsize>::max(),'\n'); // and remove the bad input

             cout<<"Invalid rating. Rating should be between 1 and 5 (inclusive)"<<endl;

             cout<<ratingType<<" rating : ";

             cin>>rating;

       }

       return rating;

}

void displayHighestRating(ProfessorRating profList[], int size)

{

       int max = 0;

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

       {

             if(profList[i].calcRating() > profList[max].calcRating())

                    max = i;

       }

       cout<<"Professor with highest rating : "<<endl;

       cout<<"Name : "<<profList[max].getName()<<endl<<"Average Rating : "<<fixed<<setprecision(2)<<profList[max].calcRating()<<endl;

}

//end of main.cpp

Output:

Add a comment
Know the answer?
Add Answer to:
COSC 1437 C++2 Project Assignment 3 Description: Computer Science Department is evaluating its professors to see...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • COSC 1437 C++ Project Assignment 2 Poll Summary Utilize a dynamic array of structure to summarize...

    COSC 1437 C++ Project Assignment 2 Poll Summary Utilize a dynamic array of structure to summarize votes for a local election Specification: Write a program that keeps track the votes that each candidate received in a local election. The program should output each candidate’s name, the number of votes received, and the percentage of the total votes received by the candidate. Your program should also output the winner of the election. To solve this problem, you will use one dynamic...

  • Data Structures and Algorithm Analysis – Cop 3530 Module 3 – Programming Assignment This assignment will...

    Data Structures and Algorithm Analysis – Cop 3530 Module 3 – Programming Assignment This assignment will access your skills using C++ strings and dynamic arrays. After completing this assignment you will be able to do the following: (1) allocate memory dynamically, (2) implement a default constructor, (3) insert and remove an item from an unsorted dynamic array of strings, (4) use the string class member functions, (5) implement a copy constructor, (6) overload the assignment operator, (7) overload the insertion...

  • C++ assignment help! The instructions are below, i included the main driver, i just need help...

    C++ assignment help! The instructions are below, i included the main driver, i just need help with calling the functions in the main function This assignment will access your skills using C++ strings and dynamic arrays. After completing this assignment you will be able to do the following: (1) allocate memory dynamically, (2) implement a default constructor, (3) insert and remove an item from an unsorted dynamic array of strings, (4) use the string class member functions, (5) implement a...

  • C++ A sample project is provided AverageGrade that is very similar to the MovieRatings project, but...

    C++ A sample project is provided AverageGrade that is very similar to the MovieRatings project, but it only is inputting one string (className) instead of both the movie name and the MPAA rating. Another difference is that the AverageGrade program scores grades A to F with point values from 4.0 to 0.0 (highest to lowest) while the MovieRatings scores the rating from 1 to 5 (lowest to highest). When using the AverageGrade program as a reference, make sure that the...

  • Instructions: Consider the following C++ program. At the top you can see the interface for the...

    Instructions: Consider the following C++ program. At the top you can see the interface for the Student class. Below this is the implementation of the Student class methods. Finally, we have a very small main program. #include <string> #include <fstream> #include <iostream> using namespace std; class Student { public: Student(); Student(const Student & student); ~Student(); void Set(const int uaid, const string name, const float gpa); void Get(int & uaid, string & name, float & gpa) const; void Print() const; void...

  • BACKGROUND Movie Review sites collect reviews and will often provide some sort of average review to...

    BACKGROUND Movie Review sites collect reviews and will often provide some sort of average review to sort movies by their quality. In this assignment, you will collect a list of movies and then a list of reviews for each movie. You will then take a simple average (total of reviews divided by number of reviews) for each movie and output a sorted list of movies with their average review. Here you are provided the shell of a program and asked...

  • A hard c++ problem ◎Write a c++ program”Student.h”include Private data member, string firstName; string lastName; double...

    A hard c++ problem ◎Write a c++ program”Student.h”include Private data member, string firstName; string lastName; double GPA(=(4.0*NumberOfAs+3.0*NumberOfBs+2.0*NumberOfCs+1.0*NumberOfDs)/( As+Bs+Cs+Ds+Fs)); Public data member, void setFirstName(string name); string getFirstName() const; void printFirstName() const; void getLastName(string name); string getLastName() const; void printLastName() const; void computeGPA(int NumberOfAs,int NumberOfBs,int NumberOfCs,int NumberOfDs,int NumberOfFs); double getGPA() const; double printGPA() const; A destructor and an explicit default constructor initializing GPA=0.0 and checking if GPA>=0.0 by try{}catch{}. Add member function, bool operator<(const Student); The comparison in this function based on...

  • Assignment Overview In Part 1 of this assignment, you will write a main program and several...

    Assignment Overview In Part 1 of this assignment, you will write a main program and several classes to create and print a small database of baseball player data. The assignment has been split into two parts to encourage you to code your program in an incremental fashion, a technique that will be increasingly important as the semester goes on. Purpose This assignment reviews object-oriented programming concepts such as classes, methods, constructors, accessor methods, and access modifiers. It makes use of...

  • It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming...

    It must be C++ Chapter 13 Programming Challenge 2: Employee Class. See instruction: Chapter 13 Programming Challenge 2 Employee Class.pdf Program Template: // Chapter 13, Programming Challenge 2: Employee Class #include <iostream> #include <string> using namespace std; // Employee Class Declaration class Employee { private: string name; // Employee's name int idNumber; // ID number string department; // Department name string position; // Employee's position public: // TODO: Constructors // TODO: Accessors // TODO: Mutators }; // Constructor #1 Employee::Employee(string...

  • For this computer assignment, you are to write a C++ program to implement a class for...

    For this computer assignment, you are to write a C++ program to implement a class for binary trees. To deal with variety of data types, implement this class as a template. The definition of the class for a binary tree (as a template) is given as follows: template < class T > class binTree { public: binTree ( ); // default constructor unsigned height ( ) const; // returns height of tree virtual void insert ( const T& ); //...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT