Develop a C++ program that reads the student’s name and scores from the attached data file “students.txt” and store them in an array of Student struct objects, then calculate and display each student’s final grade based on the following criteria: midterm exam is counted for 25% of the final grade, final exam is counted for 25% of the final grade and average of 4 labs is counted for 50% of the final grade. The format of the attached data file “txt” is --- //student name // midterm exam score, final exam score // lab1 score, lab2 score, lab3 score, lab4 score       Expected output on screen --- Define a new struct data type “Student” to represent a student record. Each student’s record should be read from the data file “txt” and stored in a variable of Student struct. Create an array of Student struct with size of 24, save all student struct records in this array. Define a function “calculateGrade(…)” which: Needs a Student struct record as parameter. Calculate this student’s final grade (numeric score). Return this student’s final grade (numeric score). All data members in the struct should be public. No non-constant data should be declared globally. Here is a sample code template --- #include #include #include using namespace std;   struct Student {         // write your code here        ………     };   // declare function prototype double calculateGrade(// write your code here ………);     int main() {         // declare all variables         Student newStudent;         Student students[24];         int numStudent = 0;         ifstream inFile;         char letterGrade = ' ';           // open the data file and check whether the file cannot be found, write your code here         ………             // read the first student’s record, write your code here         ………               while (inFile)         {               // call calculateGrade function to calculate student’s final numeric score               // and update student’s record, write your code here                ………                   // store the current student record in the students array and update numStudent               // write your code here                ………                                 // ignore the ‘\n’ at the end of current student record in the data file               // before reading next student record, write your code here                ………                                   // read next student record, write your code here                ………             }         // close the data file, write your code here         ………             for (int i = 0; i < numStudent; i++)         {               // determine each student’s letter grade (A, B, C, D or F) write your code here                ………                   // display each student’s name, final score and final grade               // according to the expected output, write your code here                ………             }         return 0; }   double calculateGrade(// write your code here ………) {         // calculate and return student’s final numeric score, write your code here         ………       }

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

Develop a C++ program that reads the student’s name and scores from the attached data file “students.txt” and store them in an array of Student struct objects, then calculate and display each student’s final grade based on the following criteria: midterm exam is counted for 25% of the final grade, final exam is counted for 25% of the final grade and average of 4 labs is counted for 50% of the final grade.

  • The format of the attached data file “txt” is ---

//student name

// midterm exam score, final exam score

// lab1 score, lab2 score, lab3 score, lab4 score

 

 

 

  • Expected output on screen ---
  • Define a new struct data type “Student” to represent a student record.
  • Each student’s record should be read from the data file “txt” and stored in a variable of Student struct.
  • Create an array of Student struct with size of 24, save all student struct records in this array.
  • Define a functioncalculateGrade(…)” which:
    • Needs a Student struct record as parameter.
    • Calculate this student’s final grade (numeric score).
    • Return this student’s final grade (numeric score).
  • All data members in the struct should be public.
  • No non-constant data should be declared globally.
  • Here is a sample code template ---

#include<iostream>

#include<fstream>

#include<string>

using namespace std;

 

struct Student

{

        // write your code here

       ………

 

 

};

 

// declare function prototype

double calculateGrade(// write your code here ………);

 

 

int main()

{

        // declare all variables

        Student newStudent;

        Student students[24];

        int numStudent = 0;

        ifstream inFile;

        char letterGrade = ' ';

 

        // open the data file and check whether the file cannot be found, write your code here

        ………

 

 

        // read the first student’s record, write your code here

        ………

 

 

 

        while (inFile)

        {

              // call calculateGrade function to calculate student’s final numeric score

              // and update student’s record, write your code here

               ………

 

 

              // store the current student record in the students array and update numStudent

              // write your code here

               ………

 

               

              // ignore the ‘\n’ at the end of current student record in the data file

              // before reading next student record, write your code here

               ………

               

 

 

              // read next student record, write your code here

               ………

 

 

        }

        // close the data file, write your code here

        ………

 

 

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

        {

              // determine each student’s letter grade (A, B, C, D or F) write your code here

               ………

 

 

              // display each student’s name, final score and final grade

              // according to the expected output, write your code here

               ………

 

 

        }

        return 0;

}

 

double calculateGrade(// write your code here ………)

{

        // calculate and return student’s final numeric score, write your code here

        ………

 

 

 

}

 

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 5 steps with 4 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

this is not correct. i am not suppose to use that header. stdio.h i am not suppose to use. everything is there in the question. please follow the guideline in the question

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education