Question: Write a program marks.c which consists of a main functi readmarks(), changemarks(), and writemarks(). The program begins by calling the function readmarks () to read consists of a series of lines containing a student ID number (an integ Once the ID numbers and marks have been read into arrays (by reač if the user wants to adjust a mark. If so, the user enters an ID num then calls the function changemarks() to change the mark associa The main then asks the user if they want to adjust another mark, student ID of 0. Finally, the main calls the function writemarks( called marksout.txt. You may assume that the input file will cons detail, your functions should perform the following;

C++ for Engineers and Scientists
4th Edition
ISBN:9781133187844
Author:Bronson, Gary J.
Publisher:Bronson, Gary J.
Chapter8: I/o Streams And Data Files
Section8.3: Random File Access
Problem 6E
icon
Related questions
Question

in C++ please

Question: Write a program marks.c which consists of a main function and three other functions called
readmarks (), changemarks (), and writemarks().
The program begins by calling the function readmarks() to read the input file marksin.txt which
consists of a series of lines containing a student ID number (an integer) and a numeric mark (a float).
Once the ID numbers and marks have been read into arrays (by readmarks()), the main program asks
if the user wants to adjust a mark. If so, the user enters an ID number and the new mark. The main
then calls the function changemarks() to change the mark associated with the provided student ID.
The main then asks the user if they want to adjust another mark, and so on, until the user enters a
student ID of 0. Finally, the main calls the function writemarks() to write the marks out to a file
called marksout.txt. You may assume that the input file will consist of no more than 20 marks. In
detail, your functions should perform the following;
main(): opens the input file marksin.txt and the output file marksout.txt and then calls
readmarks (), passing it the input file pointer, to read the IDs and marks into two arrays. Once
the arrays have been read, the main then prompts the user to enter a student ID and the revised mark,
calls changemark to revise the mark, and repeats until the user enters a student number of 0. If
changemarks () cannot find the student ID in the list of possible IDs, the main should print out an
error message, then prompt for the next student ID and revised mark. The user quits revising marks,
by entering a student ID of 0. Finally, the main calls writemarks() (passing it the output file pointer)
to write out the revised marks.
readmarks(): takes a file pointer as an argument and reads the student IDs and marks into arrays id
and marks. The function must also return the number of marks read.
changemarks (): this function should take 5 values as arguments;
1) the number of marks read,
2) the ID array,
3) the marks arrays,
4) the ID number of the student whose mark is to be revised, and
5) the revised mark.
The function
uld then revise the mark
the student with the ID specified in the 4th argument. If the
function cannot find the specified student ID in the ID array, the function should return 0. Otherwise
the function should change the mark and return 1. (NOTE: if this function returns 0, the main should
report "That student is not in the marks list" .)
writemarks (); this function should take as arguments a file pointer, the number of marks, the ID
array, and the marks array, and writes the revised marks out to the output file in the same format as
the input file (ID number followed by mark on each line).
For marking purposes, change the marks of student IDs 2315 and 2929 to 72 and 66, respectively.
Copy and paste your program into the box below.
#include <stdio.h>
#include <math.h>
#define MXN 20 /* maximum number of marks *,
int main(void)
{
/* you fill in here */
return 0;
Transcribed Image Text:Question: Write a program marks.c which consists of a main function and three other functions called readmarks (), changemarks (), and writemarks(). The program begins by calling the function readmarks() to read the input file marksin.txt which consists of a series of lines containing a student ID number (an integer) and a numeric mark (a float). Once the ID numbers and marks have been read into arrays (by readmarks()), the main program asks if the user wants to adjust a mark. If so, the user enters an ID number and the new mark. The main then calls the function changemarks() to change the mark associated with the provided student ID. The main then asks the user if they want to adjust another mark, and so on, until the user enters a student ID of 0. Finally, the main calls the function writemarks() to write the marks out to a file called marksout.txt. You may assume that the input file will consist of no more than 20 marks. In detail, your functions should perform the following; main(): opens the input file marksin.txt and the output file marksout.txt and then calls readmarks (), passing it the input file pointer, to read the IDs and marks into two arrays. Once the arrays have been read, the main then prompts the user to enter a student ID and the revised mark, calls changemark to revise the mark, and repeats until the user enters a student number of 0. If changemarks () cannot find the student ID in the list of possible IDs, the main should print out an error message, then prompt for the next student ID and revised mark. The user quits revising marks, by entering a student ID of 0. Finally, the main calls writemarks() (passing it the output file pointer) to write out the revised marks. readmarks(): takes a file pointer as an argument and reads the student IDs and marks into arrays id and marks. The function must also return the number of marks read. changemarks (): this function should take 5 values as arguments; 1) the number of marks read, 2) the ID array, 3) the marks arrays, 4) the ID number of the student whose mark is to be revised, and 5) the revised mark. The function uld then revise the mark the student with the ID specified in the 4th argument. If the function cannot find the specified student ID in the ID array, the function should return 0. Otherwise the function should change the mark and return 1. (NOTE: if this function returns 0, the main should report "That student is not in the marks list" .) writemarks (); this function should take as arguments a file pointer, the number of marks, the ID array, and the marks array, and writes the revised marks out to the output file in the same format as the input file (ID number followed by mark on each line). For marking purposes, change the marks of student IDs 2315 and 2929 to 72 and 66, respectively. Copy and paste your program into the box below. #include <stdio.h> #include <math.h> #define MXN 20 /* maximum number of marks *, int main(void) { /* you fill in here */ return 0;
Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Knowledge Booster
ADT and Class
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
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr