Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

C++ inheritance Please create a program that asks for the separate grading point

ID: 3913869 • Letter: C

Question

C++ inheritance

Please create a program that asks for the separate grading points and then gives a total and a letter grade. This program should loop around until I say that I am done. For example: (program display is bold, user input is underlined) (use .cpp and .h)

Please enter data for the next student:

Code choice/execution: (total points possible = 50): 40

Modular code: (total points possible = 20): 20

Comments and Formatting (total points possible = 10):  10

Input/Output Professionalism (total points possible = 10):  6

Jing: (total points possible = 10):  10

Calculated Total: 86

Grade: B

Do you wish to enter another assignment? (Y/N) Y

Please enter data for the next student:

Code choice/execution: (total points possible = 50): 50

Modular code: (total points possible = 20): 20

Comments and Formatting (total points possible = 10):  10

Input/Output Professionalism (total points possible = 10):  10

Jing: (total points possible = 10):  10

Calculated Total: 100

Grade: A

Do you wish to enter another assignment? (Y/N) N

Okay, bye!

Programming Requirements:

Design an Assignment class that is derived from the GradedActivity class presented in your book.  The Assignment class should determine the grade a student receives on a programming project. The student's total scores can be up to 100, and is determined in the following manner:

Code Execution: 50 points

Modular Code: 20 points

Comments and Formatting: 10 points

IO Professional: 10 points

Comments and Formatting: 10 points

Input/Output/professionalism: 10 points

Jing: 10 points

Your class should define these point categories as member variables. It must contain proper constructors and methods to hold the data and to add up the total. It will use then use setScore and getLetterGrade from the GradedActivity class to display the results.

Make sure that your member data is protected (with validation that creates an Exit_Failure when necessary).   

Make your input and output professional. Break your code down into functions as necessary.

Programming Notes:

The Assignment class is based on (inherits from) the GradedActivity.

The Assignment class will contain members for the scores and the associated mutator/accessor functions, BUT it will call the setScore function and the getLetterGrade function from GradedActivity.

GradedActivity.h
#ifndef GRADEDACTIVITY_H
#define GRADEDACTIVITY_H
class GradedActivity
{
private:
double score; // To hold the numeric score
public:
{ score = 0.0; }
{ score = s; }
{ score = s; }
{ return score; }
char getLetterGrade() const;
};
#endif

GradedActivity.cpp

#include "GradedActivity.h"
char GradedActivity::getLetterGrade() const
{
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; }

Explanation / Answer

Code

GradedActivity.h (As given in question)

#ifndef GRADEDACTIVITY_H
#define GRADEDACTIVITY_H
class GradedActivity
{
   private:
       double score; // To hold the numeric score
   public:
       GradedActivity()
       { score = 0.0; }
       GradedActivity(double s)
       { score = s; }
       double getScore()
       { return score; }

       char getLetterGrade() const;
};
#endif

GradedActivity.cpp (As given in question)

#include "GradedActivity.h"
char GradedActivity::getLetterGrade() const
{
   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;
}

Assignment.h

#ifndef ASSIGNMENT_H
#define ASSIGNMENT_H

#include "GradedActivity.h"

// inheriting graded activity class.
class Assignment: public GradedActivity {
   private:
       // members to store marks of subjects.
       double codeExecution;
       double modularCode;
       double commentsFormatting;
       double ioProfessional;
       double jing;
   public:
       // calling the superclass constructors
       Assignment(double total): GradedActivity(total){}
       // mutator/accessor functions
       double getCodeExecution();
       void setCodeExecution(double marks) ;
  
       double getModularCode() ;
       void setModularCode(double marks) ;

       double getCommentsFormatting() ;
       void setCommentsFormatting(double marks) ;

       double getIoProfessional() ;
       void setIoProfessional(double marks) ;

       double getJing() ;
       void setJing(double marks) ;
};

#endif

Assignment.cpp

#include "Assignment.h"

// funciton definition of class Assignment.
double Assignment::getCodeExecution() {
   return codeExecution;
}
void Assignment::setCodeExecution(double marks) {
   codeExecution = marks;
}

double Assignment::getModularCode() {
   return modularCode;
}
void Assignment::setModularCode(double marks) {
   modularCode = marks;
}

double Assignment::getCommentsFormatting() {
   return commentsFormatting;
}
void Assignment::setCommentsFormatting(double marks) {
   commentsFormatting = marks;
}

double Assignment::getIoProfessional() {
   return ioProfessional;
}
void Assignment::setIoProfessional(double marks) {
   ioProfessional = marks;
}

double Assignment::getJing() {
   return jing;
}
void Assignment::setJing(double marks) {
   jing = marks;
}

Main.cpp

#include <iostream>
#include <string>
#include "Assignment.h"

using namespace std;

int main() {
   do{
       // Variable to store marks.
       double ce, mc, cf, iof, jing;
       // Accepting input
       cout<< "Please enter data for the next student: ";
       cout<<"Code choice/execution: (total podoubles possible = 50): ";
       cin>>ce;
      
       cout<<"Modular code: (total podoubles possible = 20): ";
       cin>>mc;
      
       cout<<"Comments and Formatting (total podoubles possible = 10):";
       cin>>cf;
      
       cout<<"Input/Output Professionalism (total podoubles possible = 10): ";
       cin>>iof;

       cout<<"Jing: (total podoubles possible = 10): ";
       cin>>jing;

       // Calculating the total marks
       double total = ce + mc + cf + iof + jing;

      
       // Creating the assignment object.
       Assignment *assignment = new Assignment(total);

       // Setting the marks in assignment class.
       assignment->setCodeExecution(ce);
       assignment->setModularCode(mc);
       assignment->setCommentsFormatting(cf);
       assignment->setIoProfessional(iof);
       assignment->setJing(jing);

       // Displaying the total
       cout<<"Calculated Total: "<<total<<endl;;
       // calling the getLetterGrade function using assignment object.
       cout<<"Grade: "<<assignment->getLetterGrade()<<endl;;

       // Check if the user wants to continue.
       string option;
       cout<<"Do you wish to enter another assignment? (Y/N) ";
       cin>>option;
       if(option == "Y")
           continue;
       else {
           cout<<"Okay, bye! ";
           break;
       }


   }while(1);

}

Comand for code execution

g++ main.cpp Assignment.cpp GradedActivity.cpp

Sample output:

./a.out
Please enter data for the next student:
Code choice/execution: (total podoubles possible = 50): 40
Modular code: (total podoubles possible = 20): 20
Comments and Formatting (total podoubles possible = 10):10
Input/Output Professionalism (total podoubles possible = 10): 6
Jing: (total podoubles possible = 10): 10
Calculated Total: 86
Grade: B
Do you wish to enter another assignment? (Y/N) Y
Please enter data for the next student:
Code choice/execution: (total podoubles possible = 50): 50
Modular code: (total podoubles possible = 20): 20
Comments and Formatting (total podoubles possible = 10):10
Input/Output Professionalism (total podoubles possible = 10): 10
Jing: (total podoubles possible = 10): 10
Calculated Total: 100
Grade: A
Do you wish to enter another assignment? (Y/N) N
Okay, bye!

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote