Must compile on Visual studio 2015 Goals (Requirements) - No Change The program
ID: 3708301 • Letter: M
Question
Must compile on Visual studio 2015 Goals (Requirements) - No Change 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. Development Strategy (Removed from Project 3, moved to Project4) 1. We will split the code into.h and c files. 2. We will learn how to build two application from a single common code. Phase 1: 1. Split the code into two assignmentgrading3.h, assignmentgrading3.c like illustrated in the class. Phase 2: 2. Create two applications, one for student and the other for teacher. Your student and teacher applications must be fully functional. Ask for help if you are confused Bonus [10 points]: Deliver a library for assignmentgrading.h with proper README.txt file.Explanation / Answer
// define header file
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
// method definition
int Submitting_Assignment( char * asName, char* stuName, char * fName){
// declare a required variable
char op, finame[25];
FILE *Fp,*Fptr;
// opening file to read
Fp = fopen(fName, "r");
// opening file to write
Fptr = fopen("submission.txt", "w");
// check
if (Fp == NULL || Fptr == NULL)
{
printf("Error file cannot be open. ");
return 0;
}
// display
fprintf(Fptr,"%s ", asName);
fprintf(Fptr,"%s ", stuName);
// use loop
while((op = fgetc(Fp)) != EOF)
{
fprintf(Fptr,"%c", op);
}
// close a file
fclose(Fp);
fclose(Fptr);
return 1;
}
//method for defintion
int Assignments(char * asName, char* stuName, char * ass){
// declare variable
char arr[51],op;
// create a file object
FILE *Fp;
// read from the file
Fp = fopen("submission.txt", "r");
// check
if (Fp == NULL)
{
printf("Error file not opening. ");
return 0;
}
int f1 = 0,f2 = 0,i=0;
while((op = fgetc(Fp)) != EOF){
// check
if(f1==0){
if(op == ' '){
// set null
asName[i] = '';
f1 =1;
i=0;
}
// set value
asName[i] = op;
i++;
}
else if(f2 == 0){
// check
if(op == ' '){
stuName[i] ='';
f2 =1;
i=0;
}
stuName[i] = op;
i++;
}
else{
// assgin
ass[i] = op;
i++;
}
}
// close
fclose(Fp);
asName[0] = ' ';
ass[0] = ' ';
stuName[0] = ' ';
ass[i]='';
return 1;
}
// method implementation
void Execute()
{
// declare required variable
char fname[50],stuName[50],asName[50];
// create array variable
char as[1000];
int i=0;
// get user input
printf("Enter Fileaname : ");
gets(fname);
printf(" Enter your Name : ");
// get user input
gets(stuName);
// get user input
printf(" Enter Assignment Name : ");
gets(asName);
// assinging values
int val1 = Submitting_Assignment(asName,stuName,fname);
int val2 = Assignments(asName,stuName,as);
// display
printf(" Assignment:%s",asName);
printf(" Name:%s",stuName);
printf(" Assignment:");
for(i=0; as[i]!=''; i++){
printf("%c",as[i]);
}
}
// main function
int main()
{
Execute();
return 0;
}
Comment
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.