Question: Write the functions needed to complete the following program as described in the comments. Use the input file course.txt and change the mark of student

  1. Write the functions needed to complete the following program as described in the comments. Use the input file course.txt and change the mark of student number 54812 to 80.

/* File: course.cpp

A student's mark in a certain course is stored as a structure (struct student as defined below) consisting of first and last name, student id and mark in the course. The functions read() and write() are defined for the structure student.

Information about a course is stored as a structure (struct course as defined below) consisting of the course instructor, course name, course enrollment and an array of students. The functions read() and write() are defined for the structure course.

The user is allowed to change the marks of students using the function update().

*/

#include

#include

#include

using namespace std;

struct student

{

string first; // first name

string last; // last name

int id; // student id number

float mark; // mark in course

};

void read(istream& in, student& s);

void write(ostream& out, const student& s);

struct course

{

string instructor; // "Crooks", for example

string name; // "APSC2613", for example

int size; // number of students in the class

student* classlist; // array of students in the course

};

void read(istream& in, course& c);

void write(ostream& out, const course& c);

int update(course& c, int idnumber, float newmark);

int main(void)

{

course c;

int idnumber; // student id number

float newmark; // updated mark

int found; // flag indicates idnumber found

ifstream fin ("course.in");

ofstream fout ("course.out");

// read course information from the file

read(fin, c);

cout << c.size << " marks read ";

// update the marks

do

{

cout << " Enter the student id followed by the new mark ";

cout << "Enter 0 for student number to quit ";

cin >> idnumber >> newmark;

if(idnumber)

{

found = update(c, idnumber,newmark);

if(!found)

cout << " That student is not in the list ";

}

}while(idnumber != 0);

write(fout, c);

system("pause");

return 0;

}

*** Text file components

Crooks

APSC2613

4

Jack White 101102 86

Jill Green 20093 95

Bob Grey 54812 78

Jean Black 55432 89

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!