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

For C++ Write a program that uses a structure to store the following data: Membe

ID: 3874523 • Letter: F

Question

For C++

Write a program that uses a structure to store the following data:

Member Name    Description

Name Student name

Idnum Student ID number

Tests Pointer to an array of test scores

Average Average test score

Grade Course grade

The program should keep a list of test scores for a group of students. It should ask the user how many test scores there are to be and how many students there are. It should then dynamically allocate an array of structures. Each structure’sTests  member should point to a dynamically allocated array that will hold the test scores.

After the arrays have been dynamically allocated, the program should ask for the ID number and all the test scores for each student. The average test score should be cal- culated and stored in the average member of each structure. The course grade should be computed on the basis of the following grading scale:

Average Test Grade Course Grade

91–100 A

81–90 B

71–80 C

61–70 D

60 or below F

The course grade should then be stored in the Grade member of each structure. Once all this data is calculated, a table should be displayed on the screen listing each student’s name, ID number, average test score, and course grade.

Input Validation: Be sure all the data for each student is entered. Do not accept negative numbers for any test score.

Explanation / Answer

#include <iostream>

#include <string>

using namespace std;

struct student_details

{

char Name; //Student name

int Idnum; //Student ID number

int Tests; //Pointer to an array of test scores

double Average; //Average test score

char Grade; //Course grade

};

//Function prototypes

void get_data(student_details *data[20], int test_scores, int num_students);

void Calculate(student_details *data[20], int test_scores, int num_students);

void Display(student_details *data[20], int test_scores);

int main()

{

  

int num_students, test_scores;

  

//Get number of students

cout <<"How many students are there? " << endl;

cin >> num_students;

  

//Get number of test scores

cout <<"How many test scores are there? " << endl;

cin >> test_scores;

  

student_details *data[20];

data[20] = new student_details;

string Name;

double average, Idnum;

//Assign structure variable

data[20]->Name;

data[20]->Idnum;

data[20]->Tests;

data[20]->Average;

data[20]->Grade;

  

//Call functions

get_data(data, test_scores, num_students);

Calculate(data, test_scores, num_students);

Display(data, test_scores);

  

  

return(0);

}

void get_data(student_details *data[20], int test_scores, int num_students)

{

do

{

//Enter data

for (int i = 1 ;i < num_students; i++)

{   

//Prompt to enter student name

cout <<"Enter the name of student # " << i + 1 <<" here. " << endl;

cin >> data[i]->Name;

//Prompt user to enter ID number

cout <<"Enter the ID number of student # " << i + 1 << endl;

cin >> data[i]->Idnum;

}

for (int i = 0; i < test_scores; i++ )

{

cout <<"Enter the test scores # " << i + 1 << endl;

cin >> data[i]->Tests;

}

}while(test_scores < 0 );

}

//Calculate the average function

void Calculate(student_details *data[20], int test_scores, int num_students )

{

double average;

for (int i = 0; i < test_scores; i++)

{

//Display name

cout <<"Name: " << data[i]->Name << endl;

//Calculate and display average

average = data[i]->Tests / test_scores;

cout <<"The average test scores are: " << endl;

cout << average << endl;

}

}

//Display function

void Display(student_details *data[20], int test_scores )

{

double average;

//Determine scores of the students

if (average > 90 && average < 100 )

{

cout <<"You scored A " << endl;

}

else if (average > 81 && average < 90 )

{

cout <<"You scored B " << endl;

}

else if (average > 71 && average < 80 )

{

cout <<"You scored C " << endl;

}

else if (average > 61 && average < 70 )

{

cout <<"You scored D " << endl;

}

else if (average > 51 && average < 60 )

{

cout <<"You scored E " << endl;

}

else if (average < 59 )

{

cout <<"You scored F " << endl;

}

}

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