this is the essay.h file
this is the gradedActivity.h
file
this is the gradeActivity.cpp
file
Can someone help me write the
code for this in c++. I'm really struggling with this. If you can
include comments and a screenshot of the test run it would be
greatly appreciated
Note : code in bold is implemented as asked in the question
-------------------------------------
// Implementation file for the GradedActivity class
#include "GradedActivity.h"
//******************************************************
// Member function GradedActivity::determineGrade *
//******************************************************
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;
}
----------
demo
------------------------
#include <iostream>
#include "Essay.h"
using namespace std;
int main()
{
Essay essay;
double contentPoints;
double spellingPoints;
double lengthPoints;
double grammerPoints;
cout<<"Please give content points(Max 30): ";
cin>>contentPoints;
cout<<"Please give spelling points(Max 20): ";
cin>>spellingPoints;
cout<<"Please give length points(Max 20): ";
cin>>lengthPoints;
cout<<"Please give grammer points(Max 30): ";
cin>>grammerPoints;
essay.setContentPoints(contentPoints);
essay.setGrammerPoints(grammerPoints);
essay.setLengthPoints(lengthPoints);
essay.setSpellingPoints(spellingPoints);
cout<<"Your grade is:"<<essay.getLetterGrade()<<endl;
system("PAUSE");
return 0;
}
------------
graded.h
// Specification file for the GradedActivity class
#ifndef GRADEDACTIVITY_H
#define GRADEDACTIVITY_H
// GradedActivity class declaration
class GradedActivity
{
protected:
double score; // To hold the numeric score
public:
// Default constructor
GradedActivity()
{ score = 0.0; }
GradedActivity(double s)
{ score = s; }
// Mutator function
void setScore(double s)
{ score = s;}
// Accessor functions
double getScore() const
{ return score; }
char getLetterGrade() const;
};
#endif
---------
essay.h
---------
#ifndef ESSAY_H
#define ESSAY_H
#include "GradedActivity.h"
class Essay: public GradedActivity
{
private:
double grammerPoints;
double spellingPoints;
double lengthPoints;
double contentPoints;
public:
Essay(){
grammerPoints=0.0;
spellingPoints=0.0;
lengthPoints=0.0;
contentPoints=0.0;
}
void setGrammerPoints(double);
void setSpellingPoints(double);
void setLengthPoints(double);
void setContentPoints(double);
double getGrammerPoints()const {return grammerPoints;}
double getSpellingPoints()const {return spellingPoints;}
double getLengthPoints()const {return lengthPoints;}
double getContentPoints()const {return contentPoints;}
virtual char getLetterGrade();
};
#endif
-----------
essay.cpp
// Implementation file for the GradedActivity class
#include "essay.h"
//Implementing mutator functions
void Essay::setGrammerPoints(double points){
grammerPoints=points;
}
void Essay::setSpellingPoints(double points){
spellingPoints=points;
}
void Essay::setLengthPoints(double points){
lengthPoints=points;
}
void Essay::setContentPoints(double points){
contentPoints=points;
}
// implementing getLetterGrade() vitual function.
//This function needs to be modified as will be explained in your class.
// We have implemented this as it should be
//comment if you need upgradation and provide material for this function
char Essay::getLetterGrade(){
char letterGrade;
int score=grammerPoints+spellingPoints+lengthPoints+contentPoints;
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;
}
---------
output :
Please give content points (Max 30: 25 Please give spelling points (Max 20): 15 Please give length points (Max 20) 15 lease give grammer points (Max 3): 25 Your grade is:B Press any key to continue . . .
this is the essay.h file this is the gradedActivity.h file this is the gradeActivity.cpp file Can...
C++ Lab 9B Inheritance Class Production Worker Create a project C2010Lab9b; add a source file Lab9b.cpp to the project. Copy and paste the code is listed below: Next, write a class named ProductionWorker that is derived from the Employee class. The ProductionWorker class should have member variables to hold the following information: Shift (an integer) Hourly pay rate (a double) // Specification file for the ProductionWorker Class #ifndef PRODUCTION_WORKER_H #define PRODUCTION_WORKER_H #include "Employee.h" #include <string> using namespace std; class ProductionWorker...
Design an Essay class that extends the GradedActivity class presented in the chapter 10 of textbook. The Essay class should determine the grade a student receives for an essay. The student’s essay score can be up to 100 and is determined in the following manner: Grammar: 30 points Spelling: 20 points Correct length: 20 points Content: 30 points Demonstrate the class in a simple program. Example Run run: Term paper: Grammar points: 25.0 Spelling points: 18.0...
I need help implementing class string functions, any help would be appreciated, also any comments throughout would also be extremely helpful. Time.cpp file - #include "Time.h" #include <new> #include <string> #include <iostream> // The class name is Time. This defines a class for keeping time in hours, minutes, and AM/PM indicator. // You should create 3 private member variables for this class. An integer variable for the hours, // an integer variable for the minutes, and a char variable for...
please write the code in
C++
2 Base class File 3 Derived class PDF 3.1 Class declaration • The class PDF inherits from File and is a non-abstract class 1. Hence objects of the class PDF can be instantiated. 2. To do so, we must override the pure virtual function clone) in the base class • The class declaration is given below. • The complete class declaration is given below, copy and paste it into your file. . It is...
Question 2 - Programming Exercise 1. Make a directory for this lab and change into it. 2. Copy files using the following command: cp/net/data/ftp/pub/class/115/ftp/cpp/Inheritance/Exercise.cpp Exercise.cpp Finish the program so that it compiles and runs. The instructions are contained in the C++ file. Your completed program should generate output similar to the following: TwoD default constructor This program asks for the coordinates of two points in 3D space and calculates their distance. Please enter the xyz coordinates for the first point:...
Here are the files I've made so far: /********************* * File: check05b.cpp *********************/ #include <iostream> using namespace std; #include "money.h" /**************************************************************** * Function: main * Purpose: Test the money class ****************************************************************/ int main() { int dollars; int cents; cout << "Dollar amount: "; cin >> dollars; cout << "Cents amount: "; cin >> cents; Money m1; Money m2(dollars); Money m3(dollars, cents); cout << "Default constructor: "; m1.display(); cout << endl; cout << "Non-default constructor 1: "; m2.display(); cout << endl; ...
/* FILE: ./shapes7/shape.h */
#include <iostream>
using std::ostream;
class shape{
int x,y;
public:
shape( )
{ x=y=0;}
shape(int xvalue, int yvalue);
void setShape(int new_x, int new_y);
void setX(int new_x);
void setY(int new_y);
int getX( ) const;
int getY( ) const;
virtual void move(int x, int y) = 0;
virtual void shift(int dx, int dy) = 0;
virtual void draw( ) = 0;
virtual void rotate(double r) = 0;
virtual void print(ostream&)const;
friend ostream & operator<<(ostream & os, const shape& s);...
Today assignment , find the errors in this code and fixed them. Please I need help with find the errors and how ro fixed them. #include <iostream> #include <cstring> #include <iomanip> using namespace std; const int MAX_CHAR = 100; const int MIN_A = 90; const int MIN_B = 80; const int MIN_C = 70; double getAvg(); char determineGrade(double); void printMsg(char grade); int main() { double score; char grade; char msg[MAX_CHAR]; strcpy(msg, "Excellent!"); strcpy(msg, "Good job!"); strcpy(msg, "You've passed!"); strcpy(msg, "Need...
J Inc. has a file with employee details. You are asked to write a C++ program to read the file and display the results with appropriate formatting. Read from the file a person's name, SSN, and hourly wage, the number of hours worked in a week, and his or her status and store it in appropriate vector of obiects. For the output, you must display the person's name, SSN, wage, hours worked, straight time pay, overtime pay, employee status and...