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

Hi,so Im working with this code, I just got stalk on now and I am not able to fi

ID: 3828590 • Letter: H

Question

Hi,so Im working with this code, I just got stalk on now and I am not able to figure out the error this is question and my code is under it and I will have the txt file below, thanks!

99.0 1 100
87.5 1 100
103.0 2 100
96.0 2 100
48.5 2 100
78.0 2 100
10.0 3 10
98.5 3 100
73.0 3 75
98.5 3 100
97.0 3 100
100.0 3 100
100.0 4 100
96.5 4 100
95.0 4 100
94.0 4 100
80.0 4 100
90.0 4 100
100.0 4 100
10.0 4 10
20.0 4 20
15.0 4 15
9.0 5 10
8.0 5 10
10.0 5 10
7.0 5 10
14.0 5 20
20.0 5 20
17.0 5 20
21.0 5 21
10.0 5 10
5.0 5 5
71.5 6 100

Part I: Create Score Class

Write a new class for the Score. The Score should store the following:

Score

Max points for assignment

Grade type

Part II: Input Function

Write a function that will read in the data from a text file to store in the array of Scores. This function will have four parameters passed by reference:

Array of Scores

Size of the arrays

Part III: Average Function

Write a function that will compute the average of a specific grade type. This function will have four parameters passed by value and return the average.

Array of Scores

Size of the array

Part IV: Calculate Final Grade Function

Write a function that will compute the student’s final grade based on the grade type averages and their weight (you can define these in the main) towards the final grade. The input parameters will be up to you determine/customize. Just make sure the function returns the final grade (numerical).

Part V: Output Final Grade

Write a function that will output the numeric and letter grade for the student.

#include <iostream>

#include <cstdio>

#include <cstdlib>

#include <ctime>

#include <math.h>

#include <fstream>

using namespace std;

class verify {

Public:

//pass in the parameters

char letter_grade(double score) {

       char limit[][4] = { { 90,80,70,60 },{ 'A','B','C','D' } };

       for (int i = 0; i < 4; i++) {

              if (score >= limit[0][i])

                     return limit[1][i];

       }

       return 'F';

}

double calculateAverageByGrade(double score[], int Maxpointsforassignment[], int size, int gradeType) {

       int count = 0;

       double sum = 0;

}

int calculateFinalGrade(double score[],int Maxpointsforassignment[], int size, int maxGradeLimit) {

       double maxSum = 0;

       double totalScore = 0;

       double weight[] = { 0.1, 0.4, 0.2, 0.2, 0.1 };

       for (int i = 0; i < maxGradeLimit; i++) {

              // we are getting avergae for scale of 100

             

              totalScore += weight[i] * calculateAverageByGrade(score, type, Maxpointsforassignment,i+1);

              cout << totalScore << endl;

       }

       // dividing total grades to 1-5, hence for a score of 100,

       // i am dividing it by 20, to bring to scale of 1-5

       return totalScore;

}

void inputData(double score[], int Maxpointsforassignment[], int &size) {

       //open the input file

       ifstream input("X:\Downloads\lab4input.txt");

       if (input) {

              cout << "quizz grades my guy " << endl;

       }

       //In the while condition, add the instream variable

       while (input >> score[size] >> Maxpointsforassignment[size]) {

              size++;

       }

       //clsoe the file

       input.close();

}

int main() {

       //Array to store the scores

       double score[50];

       //Array to store the types

       int type[50];

       //Array to store the max points

       int max[50];

       //Size

       int size = 0;

       inputData(score, Maxpointsforassignment, size);

       // print the input data

       for (int i = 0; i < size; i++) {

              cout << "quiz " << Maxpointsforassignment[i] ,<< ", score " << score[i] << endl;

       }

       cout << " Average of Grade 1 is: " << calculateAverageByGrade(score, Maxpointsforassignment,size, 1) << endl;

       cout << "Average of Grade 2 is: " << calculateAverageByGrade(score, Maxpointsforassignment,size, 2) << endl;

       cout << "Average of Grade 3 is: " << calculateAverageByGrade(score, Maxpointsforassignment,size, 3) << endl;

       cout << "Average of Grade 4 is: " << calculateAverageByGrade(score, Maxpointsforassignment, size, 4) << endl;

       cout << "Average of Grade 5 is: " << calculateAverageByGrade(score, Maxpointsforassignment,size, 5) << endl;

       cout << " Final Grade: " << calculateFinalGrade(score, Maxpointsforassignment, size, 5) << endl;

       system("pause");

       return 0;

}

Explanation / Answer

Ans

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <math.h>
#include <fstream>

using namespace std;
class verify {
public:
//pass in the parameters
char letter_grade(double score) {
char limit[][4] = { { 90,80,70,60 },{ 'A','B','C','D' } };

for (int i = 0; i < 4; i++) {
if (score >= limit[0][i])
return limit[1][i];
}
return 'F';
}

double calculateAverageByGrade(double score[], int Maxpointsforassignment[], int size, int gradeType) {
double avg=0;
double sum=0;
      for(int i=0;i<gradeType;i++){
              sum=score[i]+sum;
          }
   avg=sum/100;
return avg;
}

int calculateFinalGrade(double score[],int Maxpointsforassignment[], int size, int maxGradeLimit) {

double maxSum = 0;
double totalScore = 0;
double weight[] = { 0.1, 0.4, 0.2, 0.2, 0.1 };
for (int i = 0; i < maxGradeLimit; i++) {
// we are getting avergae for scale of 100
cout<<score[i]<<" "<<Maxpointsforassignment[i];
totalScore += weight[i] * calculateAverageByGrade(score, Maxpointsforassignment,size ,i+1);
cout << totalScore << endl;
}

// dividing total grades to 1-5, hence for a score of 100,
// i am dividing it by 20, to bring to scale of 1-5
return totalScore;
}

void inputData(double score[], int Maxpointsforassignment[], int &size) {
//open the input file
ifstream input("lab4input.txt");
if (input) {
cout << "quizz grades my guy " << endl;
}

//In the while condition, add the instream variable
while (input >> score[size] >> Maxpointsforassignment[size]) {
size++;
}

//clsoe the file
input.close();
}
};
int main() {
   verify v;
//Array to store the scores
double score[50];
//Array to store the types
int type[50];
//Array to store the max points
int Maxpointsforassignment[50];
//Size
int size=0;
v.inputData(score, Maxpointsforassignment, size);

// print the input data
for (int i = 0; i < size; i++) {
cout << "quiz " << Maxpointsforassignment[i] << ", score " << score[i] << endl;
}

cout << " Average of Grade 1 is: " << v.calculateAverageByGrade(score, Maxpointsforassignment,size, 1) << endl;
cout << "Average of Grade 2 is: " << v.calculateAverageByGrade(score, Maxpointsforassignment,size, 2) << endl;
cout << "Average of Grade 3 is: " << v.calculateAverageByGrade(score, Maxpointsforassignment,size, 3) << endl;
cout << "Average of Grade 4 is: " << v.calculateAverageByGrade(score, Maxpointsforassignment, size, 4) << endl;
cout << "Average of Grade 5 is: " << v.calculateAverageByGrade(score, Maxpointsforassignment,size, 5) << endl;

cout << " Final Grade: " << v.calculateFinalGrade(score, Maxpointsforassignment, size, 5) << endl;

system("pause");
return 0;
}

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