Question detail as show as below:
How to design a simple grading system which able read data of a group of students. The data includes students’ names, nations, and marks of four subjects. This data is stored in a text file created by a text editor (notepad etc.).
The system should display a simple text-based menu of options and operations to be applied to the data. Upon selection of any of these operations, the results are displayed in a proper format. The grading scheme used in this system is:
Mark Grade
----------- --------
90 – 100 A
80 – 89 B
70 – 79 C
60 – 69 D
0 – 59 F

The program should be able to read students data from a data file (input.txt). The format of the data file is shown below.
Note: You must use exactly the same file format as given and the same filename (input.txt), though the data and the number of students can be different.

Felix Fiji 41 40 80 80
Philip Panama 50 50 70 70
Abel Austria 60 95 49 79
Cindy Canada 70 40 91 63

The system should allow the user to view all information, generate the statistics by subject and generate the overall statistics.

When you run the program, you should read all the data from the text file into your program and display the following:

Number of students = 4

All information is loaded from file to program.

Press any key to continue . . .

After that, the first menu to be displayed is:

Main Menu
======================================...
1. View all information
2. Statistics By Subject
3. Edit Data
0. Exit
======================================...
Please input your choice:

When the user presses 1, the system should display all information as shown below:

Name Nation English Math CPP SE Average
-------- -------- ------ ------ ------ ------ ---------
Felix Fiji 41 F 40 F 80 B 80 B 60.25 D
Philip Panama 50 F 50 F 70 C 70 C 60.00 D
Abel Austria 60 D 95 A 49 F 79 C 70.75 C
Cindy Canada 70 C 40 F 91 A 63 D 66.00 D

Press any key to continue . . .


If the user selects 2 from Main Menu, the following sub menu will be displayed:

Statistics by Subject
===========================
1. English
2. Mathematics
3. CPP
4. SE
0. Exit
===========================
Please input your choice:

Upon choosing item 1 to 4, the following sub menu will be displayed:

Statistics of English
======================================...
1. Subject Average
2. % of students below the subject average
3. % of students above the subject average
4. Display list of students based on grade
0. Exit
======================================...
Please input your choice:

Here are some examples of the above operations:

If user chooses 1, the output will be:

Average for English is --> 55.25

Press any key to continue . . .

If user chooses 2, the output will be:

Students below the average of 55.25 for English are:

Felix 41
Philip 50

Press any key to continue . . .

If user chooses 4, the user will be prompted to input a grade:

Please enter a grade (A, B, C, D, E):

Supposed the user input grade ‘C’, all the names of student who obtained grade ‘C’ for this subject will be displayed.

Students who obtained grade ‘C’ for English:

Cindy 70

Press any key to go back to the previous menu ...

p/s:
Class is allowed
No Global Variables are allowed
Thank you for helping ...
really ty
your helping was appreciated...

Recommended Answers

All 6 Replies

We're not making this homework assignment for you, show us what you've already done so far ...

Does anyone know how to write a simple crading system in C++ programming???

Yes I know

commented: LOL :P Straight and to the point :) +3

err...after this how to continue??
sorry ...what can i write is untill here...

#include <iostream>
#include <fstream>

using namespace std;

const int MAXSIZE = 20;    // Sets the maximum number of students
const string filename = "input.txt"; // Fixes the input file name

//-------------------------------------------------------------
// Class Person definition
//-------------------------------------------------------------
class Person
{
public:
	Person::Person();
	Person::Person(string, string, int, int, int, int, double);
    void Person::setName(string);
    void Person::setNation(string);
    void Person::setEnglish(int);
    void Person::setMath(int);
    void Person::setCpp(int);
    void Person::setSe(int);
    string Person::getName();
    string Person::getNation();
    int Person::getEnglish();
    int Person::getMath();
    int Person::getCpp();
    int Person::getSe();
    double Person::getAverage();

private:	
    void Person::setAverage();

	string name;
	string nation;
	int english;
	int math;
	int cpp;
	int se;
	double average;
};


//-------------------------------------------------------------
// Function prototypes
//-------------------------------------------------------------
void openFile(ifstream &);
void loadAllInfo(Person [], int &);
void viewAllInfo(Person [], int);


//-------------------------------------------------------------
//          The main function where execution starts
//-------------------------------------------------------------
int main()
{
    Person year1[MAXSIZE];
    int classSize = 0;
    loadAllInfo(year1, classSize);
    viewAllInfo(year1, classSize);
    system("pause");
	return 0;	
}


//-------------------------------------------------------------
// To display all content of the array of students in year1
// choice == '1'   from main()
//-------------------------------------------------------------
void viewAllInfo(Person year1[], int size)
{
    system("cls");
    
    string name, nation;
    int m1, m2, m3, m4, i = 0; 
   
    for (int i = 0; i <= size-1; i++) 
    {
        name = year1[i].getName();
        nation = year1[i].getNation();
        m1 = year1[i].getEnglish();
        m2 = year1[i].getMath();
        m3 = year1[i].getCpp();
        m4 = year1[i].getSe();
        
        cout << name << "\t " << nation << "\t  " << m1 << "\t "  
             << m2 << "\t  "  << m3 << "\t "  << m4 << "\t  "  << endl;
    }

    system("pause");
    return;
}

//-------------------------------------------------------------
// To read all the content of the input file and 
// to load them into the array of students in year1 and
// to update the classSize
//-------------------------------------------------------------
void loadAllInfo(Person year1[], int & classSize)
{
    system("cls");

    ifstream infile;
    openFile(infile);            // To open the input file
   
    string name, nation;
    int m1, m2, m3, m4, i = 0; 

    while( !infile.eof() )
    {
        infile >> name >> nation >> m1 >> m2 >> m3 >> m4;
        year1[i].setName(name);
        year1[i].setNation(nation);
        year1[i].setEnglish(m1);
        year1[i].setMath(m2);
        year1[i].setCpp(m3);
        year1[i].setSe(m4);

        if ( !infile.fail() )   // to avoid reading the last line twice
        {
            i++;
        }
    }

    classSize = i;
    infile.close();             // To close the input file
    cout << "\nNumber of students = " << classSize << endl;
    cout << "All information is loaded from file to program." << endl << endl;
    system("pause");
    return;
}

//-------------------------------------------------------------
// To open the text file
//-------------------------------------------------------------
void openFile(ifstream & infile)
{
    infile.open(filename.c_str());     // Refer to line 9
    if ( infile.fail() ) {
        cout << "Sorry, error in opening file!\n\n";
        system("pause");
        exit(1);
    }
}


//-------------------------------------------------------------
// all below are member functions of class Person
//-------------------------------------------------------------
Person::Person()
{
	name = "";
	nation = "";
	english = 0;
	math = 0;	
	cpp = 0;	
	se = 0;	
	average = 0;
}

Person::Person(string a, string b, int c, int d, int e, int f, double g)
{
	name = a;
	nation = b;
	english = c;
	math = d;	
	cpp = e;	
	se = f;	
	average = g;
}

void Person::setName(string a)
{
     name = a;
}

void Person::setNation(string a)
{
     nation = a;     
}

void Person::setEnglish(int a)
{
     english = a;     
}

void Person::setMath(int a)
{
     math = a;     
}

void Person::setCpp(int a)
{
     cpp = a;     
}

void Person::setSe(int a)
{
     se = a;     
}

void Person::setAverage()
{
     average = (english + math + cpp + se) / 4.0;
}

string Person::getName()
{
     return name;
}

string Person::getNation()
{
     return nation;
}

int Person::getEnglish()
{
     return english;
}

int Person::getMath()
{
     return math;
}

int Person::getCpp()
{
     return cpp;
}

int Person::getSe()
{
     return se;
}

double Person::getAverage()
{
     setAverage();
     return average;
}

That's now what happens, if you don't post using code tags you get smilies in your code which make it a mess ...

I assume You can first write a function which takes in the marks determines the grade and returns it.

I think you should explain a little more about where exactly are you stuck at.

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.