Concept explainers
Consider the following class and member function implementation. Derive a class from GradedActivity named Presentation which has two member variable ints, content and delivery which determine a Presentation’s score. Implement the following member functions for Presentation:
- a default constructor which sets both member variables and the score to zero
- a void member function named set which takes two int parameters c and d, sets content to c and delivery to d, and sets the score to c+d. This function may assume that 0 <= c+d <=100, you don't have to check it.
Additionally, provide a simple main() function which creates an object of class Presentation, uses set() to set the object’s member data with some example values, and calls getLetterGrade() to print out the letter grade.
class GradedActivity { private: int score; public: GradedActivity() { score = 0.0; } GradedActivity(int s) { score = s; } void setScore(int s) { score = s; } int getScore() { return score; } char getLetterGrade(); }; |
char GradedActivity::getLetterGrade() { char letterGrade; if (score > 89) letterGrade = 'A'; else if (score > 79) letterGrade = 'B'; else if (score > 69) letterGrade = 'C'; else if (score > 59) letterGrade = 'D'; else letterGrade = 'F'; return letterGrade; } |
Trending nowThis is a popular solution!
Step by stepSolved in 2 steps
- write the definition of a class statistics containing: three data members x, y, and z of type integer. a member function called setValues that accepts three parameters and assigns them to x, y, and z the function returns no value. a member function called getSum that accepts no parameters and returns the sum of the member variables x, y, and z. a member function called getAvg that accepts no parameters and returns the average of the member variables x, y, and z (the average should be returnsed as a double value. to do this you can use a convert function or just divide by 3.0) a member function called getMin that accepts no parameters and returns the smallest member variable. a member function called getMax that accepts no parameters and returns the largest member variable.arrow_forwardObject passing checklist1. Go over each member function and add the const keyword after their declaration ifthey do not modify any of the class' member variables.2. When accepting objects as parameters, prefer to pass them by reference. Add reference declarator (& before the identifier name of an object parameter.3. If the member function does not modify the parameter, make the parameter constantby using the const keyword. apply the Object Passing Checklist. Modify food.h and volunteer.h to useobject references. Add const and & keywords in the appropriate places of the code.arrow_forwardConsider the following definition of class Box and main function. Assuming constructor, copy constructor, assignment operator, and destructor of this class are properly without any error implemented, answer the following four questions: class Box { public: Box(); ~Box(); Box (const Box & source); fr Box& operator= (const Box & rhs); private: int* pointer; }; int main(void) { Box X; Box y(x); Box *z= new Box; x = y; return 0;arrow_forward
- Using C# language: Programming PLO-2 Measured: Design, implement, and evaluate computer solutions utilizing structured and object-oriented programming methodologies. Design a class named Contractor. The class should keep the following information: Contractor name Contractor number Contractor start date Write one or more constructors and the appropriate accessor and mutator functions for the class.arrow_forwardDefine a default constructor that initializes the data members, string title and integer year, with the default values "Empty" and -1, respectively. Ex: If the input is Magnolia 1989, then the output is: Title: Empty, Year: -1 Title: Magnolia, Year: 1989 Note: The class's print function is called first after the default constructor, then again after the inputs are passed to the setters. 5 class Book { 6 public: 7 8 9 10 11 12 13 14 15 }; 16 Book(); void SetTitle(string bookTitle); void Set Year (int bookYear); void Print (); private: string title; int year; 17 Your code goes here */ 18 19 void Book::SetTitle(string hook Title) { CS Scarint (19 bi Title mscanner 22 23 void Book Set Year(int bookYear) [ 2arrow_forward1. Driented Programming Design the class Manager that inherits from the Employee Class (defined in Question 1) and contains the two private data members, managedDepartment of integer type and managerAllowance of double type. Add the following public member methods: 1. One constructor without parameters. 2. One constructor with parameters related to managedDepartment and managerAllowance. 3. getManagedDepartment to return the managedDepartment. 4. getManagerAllowance to return the managerAllowance. 5. PrintEmplnfo to display the manager information data on the standard output. I !! public class Manager extends Employee { int managedDepartment; double managedAllowance%3;arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education