Question

In: Computer Science

Instructions: Write a program to calculate students’ average test scores and their grades. You may assume...

Instructions:

Write a program to calculate students’ average test scores and their grades.

You may assume the following input data:

Johnson 85 83 77 91 76

Aniston 80 90 95 93 48

Cooper 78 81 11 90 73

Gupta 92 83 30 69 87

Blair 23 45 96 38 59

Clark 60 85 45 39 67

Kennedy 77 31 52 74 83

Bronson 93 94 89 77 97

Sunny 79 85 28 93 82

Smith 85 72 49 75 63

Use three arrays: a one-dimensional array to store the students’ names, a (parallel) two-dimensional array to store the test scores, and a parallel one-dimensional array to store grades. Your program must contain at least the following functions: a function to read and store data into two arrays a function to calculate the average test score and grade a function to output the results. Have your program also output the class average. Use the following scale to determine the letter grade: 90%–100%, A; 80%–89.99%, B; 70%–79.99%, C; 60%–69.99%, D; and 0%–59.99%, F .

programing language: C++

Solutions

Expert Solution

C++ PROGRAM ====>

#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;

// function to display data on console
void display(string names[],double scores[][5],string grades[])
{

for(int i=0;i<10;i++)
{
cout<<left<<setw(20)<<names[i];
for(int j=0;j<5;j++)
{
cout<<left<<setw(10)<<fixed<<setprecision(2)<<scores[i][j];
}
cout<<left<<setw(10)<<grades[i]<<endl;
}

}

// function to calculate grade and store in array
int gradeStore(double scores[][5],string grades[])
{

double avg;

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

  double total =0;
for(int j=0;j<5;j++)
{
total = total+ scores[i][j];
}
avg = total/5; // calculate average

if(avg>=90)
{
grades[i]="A";
}
else if(avg>=80)
{
grades[i]="B";
}
else if(avg>=70)
{
grades[i]="C";
}
else if(avg>=60)
{
grades[i]="D";
}
else
{
grades[i]="F";
}

}
return 0;
}

// read data from txt file and store in array
int studentData(string name[],double score[][5])
{
ifstream inFile;
   inFile.open("student.txt");

string names;
   double score1, score2,score3,score4,score5;
   int i=0;

   while (inFile >>names >>score1>>score2>>score3>>score4>>score5)
   {
       name[i]=names;
score[i][0] = score1;
score[i][1] = score2;
score[i][2] = score3;
score[i][3] = score4;
score[i][4] = score5;
i++;
   }


   return 0;
}
int main()
{
// array size 10 for 10 student
string name[10];
double score[10][5];
string grade[10];

studentData( name,score);

gradeStore(score ,grade);

display(name,score,grade);


return 0;
}

OUTPUT SCREENSHOT ====>


Related Solutions

Directions: Write a program to calculate students’ average test scores and their grades. You may assume...
Directions: Write a program to calculate students’ average test scores and their grades. You may assume the following input data: Johnson 85 83 77 91 76 Aniston 80 90 95 93 48 Cooper 78 81 11 90 73 Gupta 92 83 30 69 87 Blair 23 45 96 38 59 Clark 60 85 45 39 67 Kennedy 77 31 52 74 83 Bronson 93 94 89 77 97 Sunny 79 85 28 93 82 Smith 85 72 49 75 63...
Instructions Write a Java program that asks the user t enter five test scores. The program...
Instructions Write a Java program that asks the user t enter five test scores. The program should display a letter grade for each score and the average test score. Write the following methods in the program: * calcAverage -- This method should accept five test scores as arguments and return the average of the scores. * determineGrade -- This method should accept a test score as an argument and return a letter grade for the score, based on the following...
Write a program that reads students’ names followed by their test scores. The program should output...
Write a program that reads students’ names followed by their test scores. The program should output each student’s name followed by the test scores and the relevant grade. It should also find and print the highest test score and the name of the students having the highest test score. Student data should be stored in a struct variable of type studentType, which has four components: studentFName and studentLName of type string, testScore of type int (testScore is between 0 and...
Write a C++ program that reads a file consisting of students’ test scores in the range...
Write a C++ program that reads a file consisting of students’ test scores in the range 0–200. It should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. Output the score ranges and the number of students. (Run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176,...
Write a program that will find the class average of fifteen (15) test scores for five...
Write a program that will find the class average of fifteen (15) test scores for five (5) different tests. The class average must be stored into an integer array. You are to have three separate arrays: Note: _jd represents the initials of the programmer. Your array and function names should be named by replace the initials jd with your first and last initials Arrays Student Names Scores Averages Name of array students_jd scores_jd averages_jd Size of array [15][10] [15][5] .[5]...
Write a program that reads a file consisting of students’ test scores in the range 0–200....
Write a program that reads a file consisting of students’ test scores in the range 0–200. It should then determine the number of students having scores in each of the following ranges: 0–24, 25–49, 50–74, 75–99, 100–124, 125–149, 150–174, and 175–200. Output the score ranges and the number of students. (Run your program with the following input data: 76, 89, 150, 135, 200, 76, 12, 100, 150, 28, 178, 189, 167, 200, 175, 150, 87, 99, 129, 149, 176, 200,...
(JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students...
(JAVA) Write a program that maintains student test scores in a two-dimesnional array, with the students identified by rows and test scores identified by columns. Ask the user for the number of students and for the number of tests (which will be the size of the two-dimensional array). Populate the array with user input (with numbers in {0, 100} for test scores). Assume that a score >= 60 is a pass for the below. Then, write methods for: Computing the...
Write a program that will calculate numerical and letter grades for a student and output a...
Write a program that will calculate numerical and letter grades for a student and output a report: The information will be in the provided data file studentGrades.txt. The data file consists of several rows of data containing a student name and information for 3 types of assignments: First Name, Last Name, number of homework grades, values for homework grades, percentage of total grade, number of program grades, values for program grades, percental of total grade, number of ex-am grades, values...
Write a program that will calculate numerical and letter grades for a student and output a...
Write a program that will calculate numerical and letter grades for a student and output a report: The information will be in the provided data file studentGrades.txt. The data file consists of several rows of data containing a student name and information for 3 types of assignments: First Name, Last Name, number of homework grades, values for homework grades, percentage of total grade, number of program grades, values for program grades, percental of total grade, number of ex-am grades, values...
Driver’s License test. Write a program that grades the written portion of the driver’s license test....
Driver’s License test. Write a program that grades the written portion of the driver’s license test. The test has 20 multiple choice questions. Here are the correct answers: ( use array to store ) 1.B 2.D 3. A 4. A 5. C 6. A 7. B 8. A 9. C 10. D 11.B 12. C 13. D 14. A 15. D 16. C 17. C 18. B 19. D 20. A A student must correctly answer ( use array to...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT