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 ……… }
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<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
………
}
Trending now
This is a popular solution!
Step by step
Solved in 5 steps with 4 images
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