Goals (Requirements) The program will help a student to submit a homework assign
ID: 3736355 • Letter: G
Question
Goals (Requirements) The program will help a student to submit a homework assignment as a text file. The file should contain the name of the assignment, name of the student and the actual content of the assignment as multiline text The teacher should be able to open the submitted file and assign a numerical score to it. A new file should then be created and saved that contains the name of the assignment, name of the student, the score of the assignment followed by the content of the assignment Student should be able to see the graded assignment Functional Specifications Student's Interaction 1. We will assume that student has some text written in an arbitrary text file and wants to submit it as an assignment. The text file only has the content of the work due, it does not contain the name of the assignment or the name of the stu Example: (any filename This is a sample text of a multiline assignment. This is the second 1ine of the assignment This is the third line of the assignment The program should be able to read assignments of length up to 1000 characters and arbitrary number of lines. The program will ask the student for the name of the assignment and for the name of the student The program will create a new file called "submission" txt". The first line of this file will contain the name of the assignment, and the second line contains the name of the the student. That is followed by the copy of the text 2. 3·Explanation / Answer
int submitAssignment(char * assignmentName, char *studentName, char *filename){
FILE *fp1, *fp2;
char line[80];
fp = fopen(filename, "r");
if (fp == NULL){
printf("Error opening file ");
return 0;
}
fp2 = fopen("submission.txt", "w");
fprintf(fp2,"%s ",assignmentName);
fprintf(fp2,"%s ",assignmentName);
while (fgets(data,80,fp1)!= NULL){
fprintf(fp1, "%s ",data);
}
fclose(fp1);
fclose(fp2);
}
int getAssignment(char * assignmentName, char *studentName, char *assignmnet){
FILE *fp1;
char line[80];
fp = fopen(filename, "r");
if (fp == NULL){
printf("Error opening file ");
return 0;
}
fgets(assignmentName,strlen(assignmentName),fp1);
fgets(studentName,strlen(studentName),fp1);
while (fgets(data,80,fp1)!= NULL){
assignmnet = strcat(assignment, data);
}
fclose(fp1);
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.