Please help. only have 2 days to deadline

Hi guys, I have been given 3 days to come up with a project and unfortunately I do not know enough to complete it in time so I need help and I need help fast.Fast as in tomorrow the latest(9 jan 2013)

It is a program should provide a menu( which I have completed by myself already).
*requirements are
-manage 2 kinds of students with corresponding info for undergrad & post grad.,(base class & derived classes).

undergrad=stdnt number,name,age,sex,grade,speciality,average score
postgrad=stdnt number,name,sex,age,grade,speciality,tutor,researc h area.

The menu I have created is a guideline as to what the program should be able to do.

below is the source code of what I have done so far;

[COLOR=DarkRed]#include <iostream>
#include <string>
#include<windows.h>
using namespace std;

class progMenu{
private:
string I;
string O;
string F;
string D;
string U;
string E;
public:
void menu();
void swtchboard();
void exitingOption();
};


void progMenu::menu()
{
string I="Insert student information\n";
string O="Output all students\n";
string F="Find student(s)\n";
string D="Delete student(s)\n";
string U="Update student information\n";
string E="Exit\n";
cout<<"***********************WELCOME MENU***********************\n"<<endl;

cout<<"PLEASE CHOOSE AN OPTION AND PRESS ENTER.\n\n"<<endl;

cout<<"I: "<<I<<"\nO: "<<O<<"\nF: "<<F<<"\nD: "<<D<<"\nU: "<<U<<"\nE: "<<E<<"\n"<<endl;

cout<<"***********************WELCOME MENU***********************\n"<<endl;

cout<<"PLEASE CHOOSE AN OPTION AND PRESS ENTER.\n"<<endl;
};
void progMenu::swtchboard()
{ char o;
cin>>o;
switch(o)
{
case 'I':
case 'i':
cout<<"still working Insert information"<<endl;
break;
case 'O':
case 'o':
cout<<"still working on Output all students"<<endl;
break;
case 'F':
case 'f':
cout<<"still working on Find student"<<endl;
break;
case 'D':
case 'd':
cout<<"still working on Delete student"<<endl;
break;
case 'U':
case 'u':
cout<<"still working on Update student "<<endl;
break;
case 'E':
case 'e':
exitingOption();
break;
};

};

void progMenu::exitingOption()
{
Sleep(2000);
cout<<"program is exiting...\n"<<endl;
Sleep(2000);

};



int main(){
progMenu start;

start.menu();
start.swtchboard();


system("pause");
return 0;

};
Seems pretty simple to me, Just alot of fstream play and a few .txts

if that doesn't help any then let me know and I'll help out a little more.
Use code tags (looks like <> on the right) and format your code. It's pain to read as it is now.
Specify your timezone. It is already 9 jan, where I am.

As for your problem:
Start with creating class for "undergraduate", then make a daerived class "postgraduate"

post if you have problems.
It is easier to do everything step by step.
closed account (o3hC5Di1)
Hi there,

As the previous poster said, you will need to create structs or classes for the student types.
Because they share quite some common member data, it would make sense to drive one from the other:

http://cplusplus.com/doc/tutorial/structures/
http://cplusplus.com/doc/tutorial/inheritance/#inheritance

A struct is pretty much the same as a class (except by default all its members are public), so what is said in that last link about classes applies to structs to.

After that, you will have to create a container holding the student objects, in which new students are inserted, existing students are modified, etc. This is your "database" of students if you will. You will probably want to use a std::vector<student_struct_type> for this.

Let us know which parts exactly you are struggling with, that gives you the most chance of getting proper help and fast response.

All the best,
NwN
Thanks for the replies guys but its not making too much sense. Can anyone give me a practical example, as in some sort of code. I am still a beginner at c++ & I still have a bit of trouble with it. But if I have source code I can debug and figure out what each does...
oh and another thing. When it comes to the input and output of the students. I used an array with a for loop to store the data. but now how would I retrieve the data for the output all students and output one student at a a time. please give a coded example
for all students:
1
2
3
4
for (int i=0; i< number_of_students; ++i)
{
    std::cout << student[i];
}


for 1 student:
std::cout << student[what_ever_his_index_is];
@ Darkmaster (448) thanks a lot. helped me a lot. anyone else, any other coded areas I need work on?
BTW I got an extension, its now due in 2 days
Now I need help on the following;
-what if I want to output all the students at once?
-what if I want to delete a student?
-what if I want to search/find a specific student eg. by Name or by Tutor?
(I have already input the necessary info for each student);
closed account (o3hC5Di1)
-what if I want to output all the students at once?


You do as Darkmaster told you to in his last post - use a for loop to iterate the array of students.

-what if I want to delete a student?


That depends on which way you're storing the information. If you followed the advice given here, your student array stores objects of a struct-type. In that case you could just create an "empty" student object and replace that with the one you want to delete. If you want to get fancy, you could delete it by moving every array-position after the one you wanted to delete:

1
2
3
4
5
6
7
8
int delete_index = 3;
student[delete_index] = student_t();  //make the deleted student an empty object

for (int i=delete_index; i<MAX_STUDENTS-1; i++)
{
    std::swap(student[i], student[i+1]); //move every object after the delete one
}
//the deleted, empty object is now at the end of the array 


It would be better to use a std::list though in this case rather than a regular array, it will save you a lot of headaches about tracking the state of the container.

-what if I want to search/find a specific student eg. by Name or by Tutor?


If you use a regular array:

1
2
3
4
5
6
7
8
9
student_t find(std::string search)
{
   for (int i=0; i < MAX_STUDENTS; i++)
   {
       if (student[i].name == search)
           return student[i];
   }
   return student_t();
}


Using a std::list you could use one of the std::find family of algorithms.

All the best,
NwN
I already handed in the project, did not manage to finish it, ran outta time.thanks though guys.
@ NwN I had no idea bout lists when I posted this but I have read on them and I think you are right, it would be much simpler. problem is now I do not know how to implement a linked list with nodes. do you perhaps have Skype, ill need a practical tutorial for this, it seems complex
Topic archived. No new replies allowed.