fork(2) download
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5.  
  6. //class gradedactivity (page 900)
  7. class GradedActivity
  8. {
  9. protected:
  10.  
  11. double score;
  12.  
  13. public:
  14. //default constructor
  15. GradedActivity()
  16. {
  17. score = 0.0;
  18. }
  19. //parameterized constructor
  20. GradedActivity(double s)
  21. {
  22. score = s;
  23. }
  24.  
  25. void setScore(double s)
  26. {
  27. score = s;
  28. }
  29.  
  30. double getScore() const
  31. {
  32. return score;
  33. }
  34.  
  35. char getLetterGrade() const;
  36. };
  37.  
  38. class Essay : public GradedActivity
  39. {
  40. private:
  41.  
  42. float grammar;
  43. float spelling;
  44. float length;
  45. float content;
  46.  
  47. public:
  48. Essay() {}
  49. Essay(float g, float s, float l, float c)
  50. {
  51. setGrammar(g);
  52. setSpelling(s);
  53. setLength(l);
  54. setContent(c);
  55. }
  56.  
  57. void setGrammar(float);
  58. float getGrammar();
  59. void setSpelling(float);
  60. float getSpelling();
  61. void setLength(float);
  62. float getLength();
  63. void setContent(float);
  64. float getContent();
  65. };
  66.  
  67. void Essay::setGrammar(float g)
  68. {
  69. grammar = g;
  70. }
  71. float Essay::getGrammar() {return grammar;}
  72.  
  73. void Essay::setSpelling(float s)
  74. {
  75. spelling = s;
  76. }
  77. float Essay::getSpelling() {return spelling;}
  78.  
  79. void Essay::setLength(float l)
  80. {
  81. length = l;
  82. }
  83. float Essay::getLength() {return length;}
  84.  
  85. void Essay::setContent(float c)
  86. {
  87. content = c;
  88. }
  89. float Essay::getContent() {return content;}
  90.  
  91. int main()
  92. {
  93. float grammarPts;
  94.  
  95. cout << "How many points, out of 30, did the student get for grammar?";
  96. cin >> grammarPts;
  97.  
  98. Essay object;
  99. object.setGrammar(grammarPts);
  100.  
  101. return 0;
  102. }
Success #stdin #stdout 0s 3464KB
stdin
Standard input is empty
stdout
How many points, out of 30, did the student get for grammar?