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

Write a program in c++ that fits the following recipe:a-Define a name structure

ID: 3668472 • Letter: W

Question

Write a program in c++ that fits the following recipe:a-Define a name structure template with two members: an array of characters (string) to hold the first name and an array of characters (string) to hold the second name.b. Define a student structure template with three members: a name structure, a grade array to hold three floating-point scores, and a variable to hold the average of those three scores.c. Have the main() function declare an array of CSIZE (with CSIZE = 4) student structures and initialize the name portions to names of your choice. Use functionsto perform the tasks described in parts "d," "e," "f," and "g."d. Interactively acquire scores for each student by prompting the user with a student name and a request for scores. Place the scores in the grade array portion of the appropriate structure. The requiredlooping can be done in main() or in the function, as you prefer.e. Calculate the average score value for each structure and assign it to the proper member.f. Print the information in each structure.g. Print the class average for each of the numeric structure members

Explanation / Answer

#include<iostream>

using namespace std;

#define CSIZE 4
struct name{
   char firstName[20];
   char lastName[20];
   };
struct student{
   struct name Name;
   float marks[3];
   float average;
   };
int main(){
  
   student students[CSIZE] = {{"Alex","Bagi"},{"Bob","Mital"},{"Elev","Dara"},{"Lemaon","Tree"}};
  
   for(int i=0;i<CSIZE;i++){
       cout<<"Enter Marks1 for "<<students[i].Name.firstName<<" "<<students[i].Name.lastName<<": ";
       cin>>students[i].marks[0];
       cout<<"Enter Marks2 for "<<students[i].Name.firstName<<" "<<students[i].Name.lastName<<": ";
       cin>>students[i].marks[1];
       cout<<"Enter Marks3 for "<<students[i].Name.firstName<<" "<<students[i].Name.lastName<<": ";
       cin>>students[i].marks[2];
   }
       for(int i=0;i<CSIZE;i++){
           students[i].average = (students[i].marks[0]+students[i].marks[1]+students[i].marks[2])/3.0;
           }
      
       float classAvg = 0;
       for(int i=0;i<CSIZE;i++){
           cout<<students[i].Name.firstName<<" "<<students[i].Name.lastName<<" has marks "<<students[i].marks[0]
           <<" "<<students[i].marks[1]<<" "<<students[i].marks[2]<<" in three subject, and average is "<<students[i].average<<endl;
           classAvg += students[i].average;
           }
       cout<<"Class Average: "<<(classAvg/4.0)<<endl;
      
  
   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