Question

C++ //StudentDataStructure.txt //Student records are stored in a parallel-array Data Structure. Here is the code to...

C++

//StudentDataStructure.txt

//Student records are stored in a parallel-array Data Structure. Here is the code to generate and populate Parallel-Array Data Structure:

const int NG = 4; //Number of Grades

string names[] = {"Amy Adams", "Bob Barr", "Carla Carr",
"Dan Dobbs", "Elena Evans"
};

int exams[][NG]= { {98,87,93,88},
{78,86,82,91},
{66,71,85,94},
{72,63,77,69},
{91,83,76,60}
};   

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

1 A) Create and Populate a Parallel-Array Data Structure using the code described in "StudentDataStructure.txt". B) Define a Record Data Structure for student records. It should have the same fields that you defined in the Parallel-Array Data Structure(part 1A) with additional fields for average test scores and grade.

2) Declare an array of records.

3) Populate the Record Data Structure with the data which resides in the Parallel-Array Data Structure(part 1A).

4) Define a function to display formatted student records.
   
5) Define a function to compute average and the populate average field for each record.

6) Define a function to compute the grade and
the populate grade field for each record.

7) Define a function to compute class average.

8) Define a function to compute class standard deviation.

9) Display class average and standard deviation.

Homework Answers

Answer #1

//C++ Code

#include<iostream>
#include<iomanip>
using namespace std;

struct Record {
        string name;
        int exams[4];
        double average=0;
        char grade = ' ';
};
/* a function to compute class standard deviation.*/
double calculateSDV(Record records[], int size);
/*a function to compute class average.*/
double calculateClassAvg(Record records[], int size);
/* a function to display formatted student records*/
void displayRecords(Record records[], int size);
/**
function to compute average and the populate average field for each record.
*/
void calculateAverage(Record records[], int size);
/*a function to compute the grade and
the populate grade field for each record.*/
void calculateGrade(Record records[], int size);

double calculateSDV(Record records[], int size)
{
        double sdv = 0.0;
        double mean = calculateClassAvg(records, size);
        for (int i = 0; i < size; i++)
                sdv += pow(records[i].average - mean, 2);

        return sqrt(sdv / size);
}
double calculateClassAvg(Record records[], int size)
{
        double total = 0;
        for (size_t i = 0; i < size; i++)
        {
                total += records[i].average;
        }
        return total / size;
}
void calculateGrade(Record records[], int size)
{
        for (size_t i = 0; i < size; i++)
        {
                if (records[i].average >= 80)
                        records[i].grade = 'A';
                else if (records[i].average < 80 && records[i].average >= 60)
                        records[i].grade = 'B';
                else if (records[i].average >= 40 && records[i].average < 60)
                        records[i].grade = 'C';
                else
                        records[i].grade = 'D';
        }
}
void calculateAverage(Record records[], int size)
{
        double total = 0;
        for (size_t i = 0; i < size; i++)
        {
                total = records[i].exams[0] + records[i].exams[1] + records[i].exams[2] + records[i].exams[3];
                records[i].average = total / 4;
        
        }
}
void displayRecords(Record records[], int size)
{
        cout << fixed << setprecision(2);
        for (int i = 0; i < size; i++)
        {
                cout << "(" << (i + 1) <<") Student's Name: "<<left<<setw(15)<<records[i].name<< "Marks are: " << records[i].exams[0]
                        
                        << " " << records[i].exams[1] << " " << records[i].exams[2]
                        << " " << records[i].exams[3] << "  Average: " << right << " " << records[i].average << " Grade: " << records[i].grade << endl;
        }
}
int main()
{
        /* Declare an array of records.*/
        Record records[] = { {"Amy Adams",{98,87,93,88}} ,
                {"Bob Barr", {78,86,82,91}},
                {"Carla Carr",{66,71,85,94}},
                {"Dan Dobbs",{72,63,77,69}},
                {"Elena Evans",{91,83,76,60}} };

        displayRecords(records, 5);
        calculateAverage(records, 5);
        calculateGrade(records, 5);
        cout << endl;
        displayRecords(records, 5);
        double classAvg = calculateClassAvg(records, 5);
        double sdv = calculateSDV(records, 5);

        cout << "Class Average: " << classAvg << "\nStandard Deviation: " << sdv << endl;
        return 0;
}

//Output

//If you need any help regarding this solution....... please leave a comment. thanks

Know the answer?
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for?
Ask your own homework help question
Similar Questions
Write Python code to define a class called Student. The Student class should have the following...
Write Python code to define a class called Student. The Student class should have the following private fields: name – to store the name of a student attend – to store how many times a student attend the class grades – a list of all student’s grades The Student class should have the following methods: a constructor getter method for the name field attendClass method: that increments the attend field (should be called every time a student attends the class)....
write a program that automates the process of generating the final student report for DC faculty...
write a program that automates the process of generating the final student report for DC faculty considering the following restrictions. Consider declaring three arrays for processing the student data: studID studName studGrade The student ID is a random number generated by the 5-digit system in the range of (10000 - 99999). Create a function to assign the student ID generated in an array of numbers. Consider the following to generate the random number: Add the libraries: #include <stdlib.h> #include <ctime>...
Assignment #4 – Student Ranking : In this assignment you are going to write a program...
Assignment #4 – Student Ranking : In this assignment you are going to write a program that ask user number of students in a class and their names. Number of students are limited to 100 maximum. Then, it will ask for 3 test scores of each student. The program will calculate the average of test scores for each student and display with their names. Then, it will sort the averages in descending order and display the sorted list with students’...
In the following C code, Which variable if NOT of primitive data type? A. a B....
In the following C code, Which variable if NOT of primitive data type? A. a B. b C. c D. d int a = 10; double b = 20.0; float c = false; char d[5] = "Hello"; // here we define a string In programming language C, the implementation of a string data type is limited dynamic length, which means the length of a string variable is fixed once it has been defined. A. True B. False In C# programming...
Programing lanugaue is C++ Plan and code a menu-driven modular program utilizing an array An input...
Programing lanugaue is C++ Plan and code a menu-driven modular program utilizing an array An input file has an unknown number of numeric values(could be empty too).Read the numbers from the input fileand store even numbers in one arrayand odd numbers in another array.Create menu options to Display count of even numbers, count of odd numbersand the sum values in each array Determine the average of each array Determine the median of each array Sort each array in ascending order(use...
Write the code using C++ ( from the TEXTBOOK Data Structure using C++) Add a function...
Write the code using C++ ( from the TEXTBOOK Data Structure using C++) Add a function to the dateType class. The function's name is compareDates. Its prototype is int compareDates(const dateType& otherDate; The function returns -1 if otherDate is greater than than this date The function returns 0 if otherDate equals this date The function returns 1 if otherDate is less than this date Examples dateType d1(1, 1, 2019); dateType d2(11,1, 2019) d1.compareDates(d2) returns -1 d2.compareDates(d1) returns 1 d2.compareDates(d2) returns...
Create a header file (lastname_employeerec.h) that defines an employee data structure (sEMPLOYEE) that can be linked...
Create a header file (lastname_employeerec.h) that defines an employee data structure (sEMPLOYEE) that can be linked onto a linked list. The data structure should have the following fields: a. First Name (firstName) b. Last Name (lastName) c. Employee ID (id) d. Start Year (startYear) e. Starting Salary (startSalary) f. Current Salary (currentSalary) g. next Create a library of functions that operate on this data structure. The source code for the functions should be in lastname_employeerec.c and the function prototypes should...
In c++ create a class to maintain a GradeBook. The class should allow information on up...
In c++ create a class to maintain a GradeBook. The class should allow information on up to 3 students to be stored. The information for each student should be encapsulated in a Student class and should include the student's last name and up to 5 grades for the student. Note that less than 5 grades may sometimes be stored. Your GradeBook class should at least support operations to add a student record to the end of the book (i.e., the...
In the previous assessment, you used a static set of named variables to store the data...
In the previous assessment, you used a static set of named variables to store the data that was entered in a form to be output in a message. For this assessment, you will use the invitation.html file that you modified in the previous assessment to create a more effective process for entering information and creating invitations for volunteers. Rather than having to enter each volunteer and create an invitation one at a time, you will create a script that will...
we will be taking data in as a file. you cannot use the data values in...
we will be taking data in as a file. you cannot use the data values in your source file but you must read in everything into variables and use it from there. First we need to include <fstream> at the top of our file. We will need to create an input file stream to work and ifstream. ifstream is a datatype. Create a variable with the datatype being ifstream. Variable is drfine by using the member accessor operator to call...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT