Click here to Skip to main content
15,121,030 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Example of the program: Codeboard · the IDE for the classroom[^]
The application receives assessment info and calculates the points needed to earn letter grades in this course. Assessments include all grade items from this course, (quizzes, labs, exams and final project.) The user should be able to input assessment info for all completed grade items in the course. After all of the info has been input, the program provides calculated output for how many points are needed to earn various letter grades, (A, B, C, D).

The practical application of this tool is for the student to see how many points are needed on the final exam for a specific grade in the course.

Use object-oriented programming to build this application.
At a minimum, the class structure should include the following:
private data members: title and score.
public functions to interface with the private members
each assessment should be an object of the class
To properly implement the class and collect input:
a container to store the input data as objects of the class

What I have tried:

C++
//Abdel alqawasmeh

#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main()
{
    int points = 0;
    string assignment;
    double score;
    double total;
    char choice = 'y';
    
     cout << "GRADE CALCULATOR\n"
          << "**************************\n"
          << "Please provide course grading and assignment details.\n"
          << "This program will caclulate total points earned and\n"
          << "display how many points are needed to earn different\n"
          << "letter grades for the course.\n"
          << "**************************\n";
     cout << "How many points possible for the course?: ";
     cin  >> points;

    while (tolower(choice == 'y'))
   {
      cout << endl;
      
      //getline (cin,assignment);
      cout << "ASSIGNMENT TITLE (ie week 1 lab, etc): ";
      cin >> assignment;
      getline (cin, assignment);
    
      cout << "score: ";
      cin >> score;
      
      cout << endl;
      
      cout << "Add another? (y/n): ";
      cin >> choice;
      total += score;
   }

      cout << endl;
      cout <<"**************************\n";
      cout <<"ASSIGNMENT\t\t\tSCORE";
       for (int i = 0; i < 10; i++) {
    cout << "For Counter Value: " << i << endl;
}
      cout << " " << assignment << endl;
      cout << endl;
      cout << "**************************\n";
    
    cout << " TOTAL POINTS POSSIBLE: " << points << endl;
    cout << " TOTAL POINTS EARNED: " << total << endl;
    cout << " POINTS NEEDED FOR A: " << endl;
    cout << " POINTS NEEDED FOR B: " << endl;
    cout << " POINTS NEEDED FOR C: " << endl;
    cout << " POINTS NEEDED FOR D: " << endl;
    cout << "**************************";
    
    return 0;
}

//
C++
#include "Grade.h"

const double score = 0.0;{

set_score(score);

}

double Grade::get_score() const {
  return score;
}
void Grade::set_score(const double score){
  score = score;
}
std::string Grade::get_title()const{
  return title;
}
void Grade::set_title(const std::string& title){
  title = title;
}
std::ostream& operator<<(std::ostream& os, Grade& grade){
    os << "\nAssignment: " << grade.get_title()
        << "\nScore: " << grade.get_score()
        << "\nComments: ";

    std::vector<std::string>& comments = grade.get_comments();

    if (comments.empty()){
        os << "none\n";
    }

    // will not execute if comments is empty
    for (unsigned i = 0; i < comments.size(); ++i){
        os << i+1 << ". " << comments[i] << '\n';
    }
    return os;
}

//
C++
#ifndef Grade_Calculator_H
#define Grade_Calculator_H

#include <string>
#include <vector>

class Grade
{
private:
  double score;
  std::string title;
  
public:
 Grade(double score_param = 0.0)
 {
   score = score_param;
 }
// getter and setter 
 double get_score() const
 {
   return score;
 }

 void set_score(double score_param)
 {
   score = score_param;
 }
  std::string get_title() const;
  void set_title(const std::string&);

//double get_gradeA();
//double get_gradeB();
//double get_gradeC();
//double get_gradeD();

};
#endif

//
C++
#ifndef Grade_Calculator_H
#define Grade_Calculator_H

#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <map>
#include <limits>
#include "Grade.H"
Posted
Updated 17-Nov-20 1:11am
v2
Comments
Rick York 17-Nov-20 0:47am
   
OK. Do you want applause or do you have a question?
OriginalGriff 17-Nov-20 1:56am
   
And?
What does it do that you didn't expect, or not do that you did?
What have you tried to do to find out why?
Are there any error messages, and if so, where and when? What did you do to make them happen?

This is not a good question - we cannot work out from that little what you are trying to do.
Remember that we can't see your screen, access your HDD, or read your mind - we only get exactly what you type to work with.
Use the "Improve question" widget to edit your question and provide better information.
Patrice T 17-Nov-20 7:22am
   
And you got a question ?
Member 14994778 17-Nov-20 18:52pm
   
yes, I'm trying to build a program that calculates grades in c++ using object-oriented. https://www.youtube.com/watch?v=_NWyMqfLiK4&feature=youtu.be

GRADE CALCULATOR
**************************
Please provide course grading and assignment details.
This program will caclulate total points earned and
display how many points are needed to earn different
letter grades for the course.
**************************
How many points possible for the course?: 2000

ASSIGNMENT TITLE (ie Week 1 Lab, etc): lab 1
Score: 100

Add another? (y/n): y

ASSIGNMENT TITLE (ie Week 1 Lab, etc): lab 2
Score: 100

Add another? (y/n): y

ASSIGNMENT TITLE (ie Week 1 Lab, etc): lab 3
Score: 78

Add another? (y/n): y

ASSIGNMENT TITLE (ie Week 1 Lab, etc): lab 4
Score: 89

Add another? (y/n): n

**************************
ASSIGNMENT SCORE
lab 1 100
lab 2 100
lab 3 78
lab 4 89

**************************
TOTAL POINTS POSSIBLE: 2000
TOTAL POINTS EARNED: 367
POINTS NEEDED FOR A: 1423
POINTS NEEDED FOR B: 1223
POINTS NEEDED FOR C: 1023
POINTS NEEDED FOR D: 823
**************************

1 solution

you should use the debugger to find out what is wrong. As I see the grade class istn used at all.

tip: here you should use the this syntax
C++
void Grade::set_score(const double score){
  this->score = score;
}
void Grade::set_title(const std::string& title){
  this->title = title;
}
   

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)




CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900