hi guys, im new at the forum and would like to ask for assistance with a programming assignment.

First the Question..

DEVELOPMENT OF A C++ PROGRAM FOR A STUDENT RECORD SYSTEM.
You are to develop a student record system that makes use of the C++ structure and classes.

The record system is to be used to hold information about your assignment results for year one of your degree.This will allow you to keep track of your marks for each unit of study,display the total for each unit as you progress,display the marks you need to obtain to pass the unit,as well as your average mark for the year.

The units of study,the type of assessment, and its percentage of the overall unit mark are given in the table below.


UNIT TYPE OF ASSESSMENT AND
WEIGHTING
CG037 TEST1(10%) EXAM(90%)
EN213 ASSIGNMENT1(35%)
ASSIGNMENT2(45%)
ASSIGNMENT3(20%)
EN214 ASSIGNMENT1(10%)
ASSIGNMENT2(15%)
EXAM(75%)
EN 215 ASSIGNMENT1(10%)
ASSIGNMENT2(20%)
EXAM(70%)

EN 219 ASSIGNMENT1(5%)
ASSIGNMENT2(5%)
ASSIGNMENT3(15%)
EXAM(80%)
EN 216 ASSIGNMENT1(5%)
ASSIGNMENT2(5%)
ASSIGNMENT3(10%)
ASSIGNMENT4(5%)
EXAM(75%)
EN 217 ASSIGNMENT1(20%)
ASSIGNMENT2(10%)
ASSIGNMENT3(10%)
EXAM(60%)

Your program should use a base class for member functions to:
-Enter Data into the database.
-Display a chosen unit marks(i.e.,assignment,lab,exam)with required marks needed to obtain a pass(40%) based on the marks obtained so far.
-Display all units with total marks to date in descending order,together with the average overall mark for the year.

An additional derived class should be created to:
-Save data in the database to a file.
-Read data for the database from a file into the program.
-Remove a particular data from the database and replace it with new data.
For the display of marks needed to pass you need to work out what would be required.


i have an idea of how to do it. but im not sure if it will work.. Here is a sample code i have done

#include<stdio.h>
#include<fstream.h>

struct Course{
	char CourseName [10];
	char Assignment [20];
	double mark;
};

int enterChoice(void);
void inputmarks(FILE * );
void updatemarks(FILE * );
void displaysubjectmarks(FILE * );
void displayall(FILE * );


int main()
{
	FILE *cfPtr;
	int choice;

	if( (cfPtr = fopen( "database.dat", "r+") ) == NULL)
		printf("File could not be opened. \n");
	else {
		while( ( choice = enterChoice() ) != 5) {
			switch (choice) {
			case 1:
				inputmarks( cfPtr );
				break;
			case 2:
				updatemarks( cfPtr);
				break;
			case 3:
				displaysubjectmarks(cfPtr);
				break;
			case 4:
				displayall(cfPtr);
				break;
            
			}
		}
		fclose(cfPtr);
	}
	return 0;
}

void inputmarks( FILE *readPtr)
{
	FILE *writePtr;
	struct course NewCourse = { 0, "", "", 0.0};

	if( (writePtr = fopen( "database.dat", "w") ) ==NULL)
		printf( "File could not be opened. \n");
	else {
		rewind(readPtr); printf( "\nChoose a subject:\n"
	    "1 - CG037\n"
		"2 - EN213\n"
		"3 - EN214\n"
		"4 - EN215\n"
		"5 - EN216\n " );

 
		fprintf(writePtr, "%-6s%-16s%-11s%10s\n",
			"", "Last Name", "First Name", "Balance" );

		while(!feof(readPtr) ) {
			fread( &NewCourse, sizeof(struct course), 1,
				readPtr);

			if(course.name !=0)
				fprintf(writePtr, "%-6d%-16s%-11s%10.2f\n",
				course.name
				for(//for loop to write assignments to database)
			{
				course.assignment[i]
					course.mark[i]
			});
		}

		fclose(writePtr);
	}
}
void updatemarks( FILE *fPtr)
{
	//update code
}

void displaysubjectmarks( FILE *fPtr)
{
		//code
}

void displayall(FILE *fPtr)
{
		//Code
}

int enterChoice(void)
{
	int menuChoice;

	printf( "\nEnter your choice\n"
		"1 - input marks\n"
		"2 - update marks\n"
		"3 - display subject marks\n"
		"4 - display all\n"
		"5 - end program\n? " );
	scanf( "%d", &menuChoice);
	return menuChoice;
}

i dont know if i should use two structures one for subject and one for assignment, each subject has more than two assignments. Or i should just use arrays. The problem with using an array is that the assignment number differ for each subjects, e.g CG037 has only one assignment and exam whil EN213 has three assignments and no exam at all..

I will keep working on it and post more code later..

VernonDozier commented: Used code tags on first post. :) +12
Member Avatar for jencas

Use STL containers like std::vector instead of arrays

Yes use two structures.

Alrite.. thnx for the reply

im still working on it, i will ask for assistance if i get stuck.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.