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

I\'ve been working on an assignemnt for school which I can get working on my own

ID: 3681405 • Letter: I

Question

I've been working on an assignemnt for school which I can get working on my own but I can never figure out how to tie it all togeather. Assistance is most appericated. The assignment reads as follows.

Write a program that asks the user to enter five test scores and with each score a student’s first name. The program should display a letter grade for each score followed by the students name and the average test score.

  
calculate_average This function should accept five test scores as arguments and return the average of the scores.

determine_grade —This function should accept a test score as an argument and return a letter grade for the score based on the following grading scale:


Score Letter Grade

90–100 A

80–89 B
70–79 C

60–69 D

Below 60 F

Program output should look like this:

Enter Score 1: 98

Enter Name 1: Bob

Enter Score 2: 55

Enter Name: John

Enter Score 3: 78

Enter Name: Billy

Enter Score 4: 64

Enter Name 4: Tom

Enter Score 5: 86

Enter Name 5: James

Name Numeric Grade Letter Grade

-------------------------------------------------------------------------------------------

Bob 98 A

John 55 F

Billy 78 C

Tom 64 D

James 86 B

Explanation / Answer

/****** C++ code to find grade and average of scores ***********/

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

using namespace std;

char determine_grade (double grade_number) // function to find grade
{
       char grade;
       if(grade_number >= 90 && grade_number <= 100) grade = 'A';
       else if(grade_number >= 80 && grade_number < 90) grade ='B';
       else if(grade_number >= 70 && grade_number < 80) grade ='C';
       else if(grade_number >= 60 && grade_number < 70) grade ='D';
       else if(grade_number < 60) grade ='F';

       return grade;  
}


double calculate_average (double score[])
{
   double sum =0;
   for (int i = 0; i < 5; ++i)
   {
       sum = sum + score[i];
   }

   return sum/5;
}


int main()
{
   while(1)
   {
       double score[5];
       string name[5];
      
       cout << "Enter Score 1: ";
       cin >> score[0];
       cout << "Enter Name 1: ";
       cin >> name[0];
       cout << "Enter Score 2: ";
       cin >> score[1];
       cout << "Enter Name 2: ";
       cin >> name[1];
       cout << "Enter Score 3: ";
       cin >> score[2];
       cout << "Enter Name 3: ";
       cin >> name[2];
       cout << "Enter Score 4: ";
       cin >> score[3];
       cout << "Enter Name 4: ";
       cin >> name[3];
       cout << "Enter Score 5: ";
       cin >> score[4];
       cout << "Enter Name 5: ";
       cin >> name[4];


       cout<<"Name Number Grade Letter Grade ";
       cout<<"---- ------------- ------------- ";
       for (int i = 0; i < 5; ++i)
       {
           cout<<name[i]<<" "<<score[i]<<" "<<determine_grade(score[i])<<endl;
       }

       cout<<"Average of all scores is: "<< calculate_average(score)<<endl<<endl;

       char c;
       printf("Calculate another student grade: (press Y for Yes, press N for No): ");
       scanf("   %c",&c);
       if(c == 'N' || c == 'n') return 0;

   }
   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