Question

I have homework that asks to create C++ program to include: 1A) Create and populate a...

I have homework that asks to create C++ program to include:

1A) Create and populate a parallel-array Data Structure using the following code:

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

const int NG = 4; //Number of Grades

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

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

1B) Define a Record Data Structure for student grade records.
It should have the same fields that you defined in the
Parallel-Array Data Structure(part 1A) with additional
fields for average assessment score 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.

10) Demonstrate ALL functions that you created.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Here is the answer for your question in C++ Programming Language.

Kindly upvote if you find the answer helpful.

NOTE : According to the HOMEWORKLIB POLICY, experts are allowed to answer a max of four sub parts when given multiple sub parts ina single question. Answered as per the HOMEWORKLIB POLICY. Apologie for this.

I have answered parts (1- 7)

CODE :

#include<iostream>
#include<string>
#include<iomanip>

using namespace std;


//4) Define a function to display formatted student records.
void displayStudentRecords();

/*5) Define a function to compute average and
the populate average field for each record.*/
void computeAverage();

/*6) Define a function to compute the grade and
the populate grade field for each record.*/
void computeGrade();

//7) Define a function to compute class average.
void computeClassAverage();

/*1B) Define a Record Data Structure for student grade records.
   It should have the same fields that you defined in the
   Parallel-Array Data Structure(part 1A) with additional
   fields for average assessment score and grade.*/
struct Record{
   string name;
   int assessment[4];
   double average;
   char grade;
};
//2) Declare an array of records.
struct Record records[5]; //Since there are 5 student names in names[] array
int main(){
  
   //1A) Create and populate a parallel-array Data Structure using the following code:
   //Student grade records are stored in a parallel-array Data Structure.
   //Here is the code to generate and populate
   //the Parallel-Array Data Structure:  
   const int NG = 4; //Number of Grades  
   string names[] = {"Amy Adams", "Bob Barr", "Carla Carr","Dan Dobbs", "Elena Evans"};
  
   int assessment[][NG]= { {98,87,93,88},
                           {78,86,82,91},
                           {66,71,85,94},
                           {72,63,77,69},
                           {91,83,76,60} };       
  
   /*3) Populate the Record Data Structure with the data which
       resides in the Parallel-Array Data Structure(part 1A).*/
   for(int i=0;i<5;i++){
       records[i].name = names[i];
       for(int j=0;j<4;j++)
           records[i].assessment[j] = assessment[i][j];          
   }
   //Call function displayStudentRecords
   displayStudentRecords();
   //Call function computeAverage
   computeAverage();
   //Call function computeGrade()
   computeGrade();  
  
   //Display average and grades for each records
   cout << left << setw(20) << "Name " << left << setw(20) << "Average " << left << setw(20) << "Grade" << endl;
  
   cout << "*******************************************************" << endl;
   for(int i=0;i<5;i++){
       cout << left << setw(20) << records[i].name << left << setw(20) << records[i].average << left << setw(20) << records[i].grade << endl;         
   }
   //Call method computeClassAverage()
   computeClassAverage();
}
void displayStudentRecords(){
   cout << "********************************************************************************************" << endl;
   cout << left << setw(20) << "Name " << left << setw(20) << "Assessment 1 " <<
   left << setw(20) << "Assessment 2" << left << setw(20) << "Assessment 3" << left << setw(20) << "Assessment 4" << endl;
   cout << "********************************************************************************************" << endl;
   for(int i=0;i<5;i++){
       cout << left << setw(20) << records[i].name << left << setw(20) << records[i].assessment[0]
       << left << setw(20) << records[i].assessment[1] << left << setw(20) << records[i].assessment[2] << left << setw(20) << records[i].assessment[3] << endl;
   }
}
//Method that computes average for each record
void computeAverage(){
   int sum = 0;  
   for(int i=0;i<5;i++){
       sum = 0;
       for(int j=0;j<4;j++)
           sum += records[i].assessment[j];
       records[i].average = sum/(double)4;
   }
}
//Method that computes grade for each record
void computeGrade(){
   for(int i=0;i<5;i++){
       if(records[i].average >=90 && records[i].average <= 100){
           records[i].grade = 'A';
       }
       else if(records[i].average >=80 && records[i].average < 90){
           records[i].grade = 'B';
       }
       else if(records[i].average >= 70 && records[i].average < 80){
           records[i].grade = 'C';
       }
       else if(records[i].average >= 60 && records[i].average < 70){
           records[i].grade = 'D';
       }
       else if(records[i].average < 60){
           records[i].grade = 'F';
       }
   }
}
//Method that computes class average
void computeClassAverage(){
   double sum = 0;
   for(int i=0;i<5;i++){
       sum += records[i].average;
   }
   cout << "*****************************" << endl;
   cout << "Class average : " <<fixed << setprecision(2) << sum/5;
}

SCREENSHOTS :

Please see the screenshots of the code below for the indentations of the code.

1 #include<iostream> 2 #include<string> 3 #include<iomanip> 4 5 using namespace std; 6 7 1/4) Define a function to display fo

олол 32 struct Record records[5]; //Since there are 5 student names in names[] array 33 int main() { 34 35 //14) Create and p

********* } } 63 cout << left << setw(20) << Name << left << setw(20) << Average << left << setw(20) << Grade << endl;

} } بہ 코 } 95 for(int i=0;i<5;i++){ 96 if (records[i].average >=90 && records[i].average <= 100){ 97 records[i].grade = A;

OUTPUT :

******* ********* Name Assessment 1 Assessment 2 Assessment 3 Assessment 4 *************** **********************************

Any doubts regarding this can be explained with pleasure :)

Add a comment
Know the answer?
Add Answer to:
I have homework that asks to create C++ program to include: 1A) Create and populate a...
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. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Note: Please do this in C++ Currently, Marvel Academy's student grade records are stored parallel arrays...

    Note: Please do this in C++ Currently, Marvel Academy's student grade records are stored parallel arrays string names []"Spider-Man", "Iron Man","Black Panther","Dr. Strange", "Thor"i int exams[1 [4- 98,96, 93,88, 60, 91,99,74 95, 85,94,88 t 100,100, 99,100, 58, 83,76,60 We want to convert these to a dynamic array of structures with an additional exam average field Your tasks are: 1. define a structure for student grade records 2. declare a dynamic array of structures 3. populate the structures from the parallel...

  • In C++, write a complete program that receives a series of student records from the keyboard...

    In C++, write a complete program that receives a series of student records from the keyboard and stores them in three parallel arrays named studentID and courseNumber and grade. All arrays are to be 100 elements. The studentID array is to be of type int and the courseNumber and grade arrays are to be of type string. The program should prompt for the number of records to be entered and then receive user input on how many records are to...

  • The following C++ program is a slightly modified version of Program 5.20 from Gary J. Bronson...

    The following C++ program is a slightly modified version of Program 5.20 from Gary J. Bronson textbook. In this program, you compute and display the average of three grades of each student for a class of four students. You need to modify the code to compute and display the class average as well as the standard deviation. Your code changes are as follows: 1. The variable “double grade” should be replaced by a two-dimensional array variable “double grade[NUMSTUDENTS][NUMGRADES].” Also replace...

  • Write a C++ program that asks user number of students in a class and their names....

    Write a C++ program that asks 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’ names and ranking. Follow the Steps Below Save the project as A4_StudentRanking_yourname....

  • c++ help Write a program that: Creates two finite arrays of size 10 These arrays will...

    c++ help Write a program that: Creates two finite arrays of size 10 These arrays will serve as a storing mechanism for student grades in Classes A and B Uses a loop to populate the arrays with randomly generated numbers from 0 to 100.These numbers will represent student grades. Compute average grade of each class. Finally, output the two arrays and the message with two averages and best class. ("Class A average is: 65.43; class B average is: 68.90. Class...

  • Write a complete C++ program that reads students names and their test scores from an input...

    Write a complete C++ program that reads students names and their test scores from an input text file. The program should output each student’s name followed by the test scores and the relevant grade in an output text file. It should also find and display on screen the highest/lowest test score and the name of the students having the highest/lowest test score, average and variance of all test scores. Student data obtained from the input text file should be stored...

  • Must be done in C# please! Thanks! In this assignment you will create a program named...

    Must be done in C# please! Thanks! In this assignment you will create a program named Test Scores that displays the average of all tests; average midterm score; average final score; and displays the midterm or final score of a particular student. Create a class level two dimensional integer array named Grades initialized with the following data: 897 242 301 987 116 450 865 128 992 109 88 75 94 70 90 87 81 79 97 79 78 80 92...

  • Create a C program to implement a grade book. Must follow these guidelines: 1. Use #define...

    Create a C program to implement a grade book. Must follow these guidelines: 1. Use #define to define MAX_SIZE1 as 20, and MAX_SIZE2 as 10 2. Use typedef to define the following struct type: struct { char name[MAX_SIZE1]; int scores[MAX_SIZE2]; } 3. The program accepts from the comand line an integer n (<= 30) as the number of students in the class. You may assume that the input will always be valid. 4. Dynamically allocate memory for an array of...

  • Using C programming For this project, you have been tasked to read a text file with student grade...

    Using C programming For this project, you have been tasked to read a text file with student grades and perform several operations with them. First, you must read the file, loading the student records. Each record (line) contains the student’s identification number and then four of the student’s numerical test grades. Your application should find the average of the four grades and insert them into the same array as the id number and four grades. I suggest using a 5th...

  • using C++ language!! please help me out with this homework In this exercise, you will have...

    using C++ language!! please help me out with this homework In this exercise, you will have to create from scratch and utilize a class called Student1430. Student 1430 has 4 private member attributes: lastName (string) firstName (string) exams (an integer array of fixed size of 4) average (double) Student1430 also has the following member functions: 1. A default constructor, which sets firstName and lastName to empty strings, and all exams and average to 0. 2. A constructor with 3 parameters:...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT