- #1
jnbankwa
- 14
- 0
Dear please read this exercise and the codes and tells me what wrong with you codes
Part 1
You are provided with a skeleton program, where the data is stored in arrays. Your task is to add the code that will do the following:
Examine the data in the arrays. The data shows the results from marking a set of student assignments. The arrays contain the Marker who was assigned this piece of work (set to 1 for the first person marking the students and 2 for the other person marking the students), the student Id, and the Mark awarded. (Your program has to count how many students were marked by each marker in order to calculate the averages correctly.) Your program must then display the two averages and how many students each marker marked.
The results should look as below:
Part 2
Change your program so that it no longer uses sets of arrays, but instead declares a struct called Assignment for each student and uses a single array of these. Your program must read the information in from a file called marks.txt (which is already supplied in the folder), which contains the same information as the arrays.
You should produce the same display, because the information is the same.
Your program must also write the summary results as shown on screen to another file called “summaryN12345.txt” where N12345 is your NTU ID.
Part 3
During the moderation process, it has been realized that marker 1 and marker 2 have very different averages. To correct this you must write a function called Moderate which has a void return and a single parameter of a pointer or reference to the struct Assignment. This function must be called for every assignment in the array. If the parameter denotes an Assignment marked by marker 1, the body of the function must increase the mark by 20% of its current value (ie a mark of 50 would be increased by 20% of its value to 60). Your display must now show the effect of these changes:
Part 1
You are provided with a skeleton program, where the data is stored in arrays. Your task is to add the code that will do the following:
Examine the data in the arrays. The data shows the results from marking a set of student assignments. The arrays contain the Marker who was assigned this piece of work (set to 1 for the first person marking the students and 2 for the other person marking the students), the student Id, and the Mark awarded. (Your program has to count how many students were marked by each marker in order to calculate the averages correctly.) Your program must then display the two averages and how many students each marker marked.
The results should look as below:
Part 2
Change your program so that it no longer uses sets of arrays, but instead declares a struct called Assignment for each student and uses a single array of these. Your program must read the information in from a file called marks.txt (which is already supplied in the folder), which contains the same information as the arrays.
You should produce the same display, because the information is the same.
Your program must also write the summary results as shown on screen to another file called “summaryN12345.txt” where N12345 is your NTU ID.
Part 3
During the moderation process, it has been realized that marker 1 and marker 2 have very different averages. To correct this you must write a function called Moderate which has a void return and a single parameter of a pointer or reference to the struct Assignment. This function must be called for every assignment in the array. If the parameter denotes an Assignment marked by marker 1, the body of the function must increase the mark by 20% of its current value (ie a mark of 50 would be increased by 20% of its value to 60). Your display must now show the effect of these changes:
Code:
// ExtendedtestA.cpp : Defines the entry point for the application.
// Author:
// ID:
// Version:
// Date: 6 Jun 2011
// Description:
#include "stdafx.h"
#include "gwin.h"
using namespace std;
const int NUMSTUDENTS = 11;
int ID [NUMSTUDENTS] = {10001, 10011, 10012, 1004, 1005, 1006, 1007, 1008, 1009, 1010,1011};
double Score [NUMSTUDENTS] = {47.5, 62.0, 34.5, 59.0, 68.0, 42.5, 81.5, 36.5, 55.0, 63.5, 45.8};
int WhoMarked [NUMSTUDENTS] = {2,1,1,2,2,1,2,1,1,2,1};
struct marks
{
int ID [NUMSTUDENTS];
double Score [NUMSTUDENTS];
int WhoMarked [NUMSTUDENTS];
int Marker 1[NUMSTUDENTS];
int Marker 2 [NUMSTUDENTS];
void ApplyReheat(marks*marks)
{
marks->Score=marks->Score/11;
}
int main()
{
GWindow Gwin;
Marker 1 Marked[NUMSTUDENTS];
Marker 2 Marked[NUMSTUDENTS];
ifstream marks("marks.txt");
int n=0;
while (!marks.eof())
{
marksfile >>listing[n].ID;
marksfile >>listing[n]. Score;
marksfile >>listing[n]. WhoMarked;
n++;
if (n== NUMSTUDENTS)
break;
}
Gwin.clear();
Gwin.setPenColour(BLACK);
Gwin.writeText(10,10,"Marker 1 Marked giving an average of ");
Gwin.writeText(10,30,"Market 2 Marked giving an average of ");
int count=0;
int y=20;
double twr=0;
int Average=0;
double Marks=0
while (count< NUMSTUDENTS)
{
ApplyReheat (&listing[count]);
Gwin.writeText(10,y,listing[count].Score);
Gwin.writeInt(50,y,listing[count].WhoMarked);
Average=(listing[count].ID*listing[count].Score)/listing[count]. WhoMarked;
Gwin.writeDouble(100,y,twr);
if (twr > Marks)
{
Marks=twr;
Average=count;
}
if (twr>1)
Gwin.writeText(150,y,"X");
count++;
y+=10;
if (count== NUMSTUDENTS)
break;
}
Gwin.writeText(10,y,"Average is :");
Gwin.writeText(200,y, listing[n]. Score. WhoMarked/11);
Gwin.writeDouble(250,y,Marks);
Keyboard.waitKey();
return 0;
}
Last edited by a moderator: