[08.04.2010] Progress Report
Unix C++ :: UNIX CPP :: CPP :: Case Studies
Page 1 of 1
[08.04.2010] Progress Report
You are a software developer. The management of a school has approached you to
create a Progress report software. The specification and documentation you have
gathered from your client is as follows.
Whenever the client open( execute ) the software it will show you main menu having three options. 1st for entering data, 2nd for viewing the existing data and 3rd for backup of existing data.
If the user choose the first option(entering data) , it will ask individual student’s data to input namely 1) Name : 2) Roll No. : 3) Class : 4) Individual marks for 6 subjects for each student. : 5) Section (e.g. A, B, C …. Etc ) and 6) Parent name : .
After entering one student’s details it will ask whether to continue to the next student’s details( Y/N ). If no, then it will again go back to the main menu, asking for the option.
If the user choose 2nd option (viewing the existing data ) then it will ask for entering Roll no. of the respective student searching for. If the Roll no. is not mapped with the existing data, system will make you know “Data is not available”.
In case of viewing the data if the Roll no. is mapped with the existing data it will show the Progress Report of the respective student along with data namely, 1) Name of the School 2) Name : 3) Roll No. : 4) Class : 5) Individual marks for 6 subjects for each student. : 6) Section (e.g. A, B, C …. Etc ) and 7) Parent name : 8.) Total marks obtain
9) Average percentage 10) Depending on the average marks, grade will be shown as ( >=90% A+, <90%>=80% A, <80%>=60% B, <60%>=50% C, <50 Disqualified )
Report should be in proper conventional format.
If the user choose 3rd option, it will create the backup files for the existing files in different physical location.
The data should be stored in flat data files for permanent storage.
SOLUTION
I have not used vectors instead of arrays. Only declaration stmt has to be changed.
create a Progress report software. The specification and documentation you have
gathered from your client is as follows.
Whenever the client open( execute ) the software it will show you main menu having three options. 1st for entering data, 2nd for viewing the existing data and 3rd for backup of existing data.
If the user choose the first option(entering data) , it will ask individual student’s data to input namely 1) Name : 2) Roll No. : 3) Class : 4) Individual marks for 6 subjects for each student. : 5) Section (e.g. A, B, C …. Etc ) and 6) Parent name : .
After entering one student’s details it will ask whether to continue to the next student’s details( Y/N ). If no, then it will again go back to the main menu, asking for the option.
If the user choose 2nd option (viewing the existing data ) then it will ask for entering Roll no. of the respective student searching for. If the Roll no. is not mapped with the existing data, system will make you know “Data is not available”.
In case of viewing the data if the Roll no. is mapped with the existing data it will show the Progress Report of the respective student along with data namely, 1) Name of the School 2) Name : 3) Roll No. : 4) Class : 5) Individual marks for 6 subjects for each student. : 6) Section (e.g. A, B, C …. Etc ) and 7) Parent name : 8.) Total marks obtain
9) Average percentage 10) Depending on the average marks, grade will be shown as ( >=90% A+, <90%>=80% A, <80%>=60% B, <60%>=50% C, <50 Disqualified )
Report should be in proper conventional format.
If the user choose 3rd option, it will create the backup files for the existing files in different physical location.
The data should be stored in flat data files for permanent storage.
SOLUTION
- Code:
/*
* ProgrssReport.cpp
*
* Created on: Apr 8, 2010
*
* DEVELOPED AND MAINTAINED BY CHRISTOPHER PRAVEEN
*/
#include<iostream.h>
#include<fstream.h>
#include<string.h>
using namespace std;
class Student
{
string name;
string fathername;
int rollno;
int marks[5];
string section;
int cls;
public:
void write()
{
cout << "Roll Number : ";
cin >> rollno;
cout << "Class : ";
cin >> cls;
cout << "Section : ";
cin >> section;
cout << "Student Name : ";
cin >> name;
cout << "Father Name : ";
cin >> fathername;
cout << "Marks : ";
for (int i = 0; i < 5; i++)
cin >> marks[i];
ofstream fs;
fs.open("StudHistory.txt", ios::out | ios::app | ios::binary);
fs << name << " " << fathername << " " << cls <<" "<<section<< " " << rollno;
for (int i = 0; i < 5; i++)
fs << " " << marks[i];
}
bool read(int rno)
{
ifstream is;
int tot = 0;
float avg = 0.0;
is.open("StudHistory.txt");
bool found = false;
while (!is.eof())
{
is >> name >> fathername >> cls >>section >> rollno;
for (int i = 0; i < 5; i++)
is >> marks[i];
if (rollno == rno)
{
found = true;
cout << "Student Name : ";
cout << name << endl;
cout << "Father Name : ";
cout << fathername << endl;
cout << "Class : ";
cout << cls << endl;
cout << "Section : ";
cout << section << endl;
cout << "Roll Number : ";
cout << rollno << endl;
cout << "Marks : ";
for (int i = 0; i < 5; i++)
{
cout << marks[i] << " ";
tot = tot + marks[i];
}
avg = tot / 5;
cout << endl;
cout << "Total : " << tot << endl;
cout << "Average : " << avg << endl;
break;
}
}
return found;
}
};
char displayMenu()
{
char choice;
cout << endl << endl << endl << endl << endl;
cout << "MENU" << endl << endl;
cout << "1. Insert Data" << endl;
cout << "2. View Data" << endl;
cout << "3. Backup Data" << endl;
cout << "4. Quit" << endl;
cout << endl << endl << "Enter choice : ";
cin >> choice;
return choice;
}
void copyToFile(char *filename)
{
char a;
ofstream os;
ifstream is;
os.open(filename);
is.open("StudHistory.txt");
while (!is.eof())
{
is >> a;
os << a;
}
}
int main()
{
char choice;
Student s;
char ans;
int rno;
bool cont = true;
bool found = false;
char* filename;
choice = displayMenu();
while (cont)
{
switch (choice)
{
case '1':
REPEAT: s.write();
cout << endl << endl << "Wish to continue (y/n) ? ";
cin >> ans;
if (ans == 'y')
goto REPEAT;
else
choice = displayMenu();
break;
case '2':
ONCEAGAIN: cout << "Roll No : ";
cin >> rno;
found = s.read(rno);
if (found == false)
cout << endl << endl << "Record Not Found" << endl << endl;
cout << endl << endl << "Wish to continue (y/n) ? ";
cin >> ans;
if (ans == 'y')
goto ONCEAGAIN;
else
choice = displayMenu();
break;
case '3':
ANOTHER: cout << "Filename : ";
cin >> filename;
copyToFile(filename);
cout << endl << endl << "Wish to continue (y/n) ? ";
cin >> ans;
if (ans == 'y')
goto ANOTHER;
else
choice = displayMenu();
break;
default:
cout << endl << endl << "THANK U";
cont = false;
}
}
}
I have not used vectors instead of arrays. Only declaration stmt has to be changed.
Last edited by Christopher on Fri Apr 09, 2010 1:22 pm; edited 1 time in total
Re: [08.04.2010] Progress Report
Also grading system has not been implemented. Just use 'if' block to display grade.
Re: [08.04.2010] Progress Report
If someone has implemented this in a different way, post ur solution.
Unix C++ :: UNIX CPP :: CPP :: Case Studies
Page 1 of 1
Permissions in this forum:
You cannot reply to topics in this forum
|
|