hi guy's , iam a new member i got stuck with my c++ assigment. i really want's your help

the program reads in a series of student data sets from the keyboard, stores
them in an ordered linked list of records, supports editing an existing record, and displays a
summary of all students entered. Each student’s record should contain the following fields:
First name
Last name
ID #
Midterm grade
Final Exam Grade
The linked list should be sorted by last name. The program should be menu driven, with the
following menu options:
Enter new student
Edit existing student (search by name)
Display list
Exit
The following details apply:
- Each student data record should be dynamically allocated
- The records should be stored in a linked list
- The records in the linked list should be sorted alphabetically by last name
- When editing is selected, the user should be prompted for the last name of the student record to edit.
--------------------------
this is what i wrote so far

#include <iostream>
#include <string>
#include <cstdlib>
using namespace std;

#define SIZE 100

char ans;

int main () 
{

	cout <<" Welcome to bos3ayed C++ writer company "<<endl;
	cout << " this program help you to orginzing your student information";
	cout<<". first name , last name , ID, first midterm grade, and final"<<endl;
	cout <<endl<<endl;
	cout<< "Choose what do you want to do from this menu (a,b,c,d)"<<endl;
	cout<<"a) Enter new student"<<endl;
	cout<<"b) Edit existing student ( serch by name)"<<endl;
	cout<<"c) Display list "<<endl;
	cout<<"d) Exit"<<endl;
	cin>> ans;

}

class student_list
{
	private:
		char First_name [SIZE];
		char Last_name [SIZE];
		int ID;
		float mid_grade,final_grade;

	public: 
		student_list *next;
};

    student_list::student_list() {
	student_list *temp , *head;
	temp = new student_list;  // dynamiclly allocationg
	temp -> next = NULL;
	cout << "Enter student first name "<<endl;
	cin >> temp-> First_name;
	cout << "Enter student last name "<<endl;
	cin>> temp-> Last_name;
	cout<< "please enter student ID "<<endl;
	cin>>temp->ID;
	cout<<"please enter midterm grade"<<endl;
	cin>> temp->mid_grade;
	cout<<"please enter final grade"<<endl;
	cin>> temp->final_grade;
}

student_list *head,*ptr,*tmp;
head=NULL;

while () {
	
	ptr=new student_list;
	temp=head;
	head=ptr;
	head->next=tmp;

}

----------------------------
thanks in advance;

Not sure where to start on this one... You haven't really followed the instructions. The instructions state that EACH student data record should be dynamically allocated. Instead your student list creates a static sized array of 100 records. What you need to do is make a StudentRecord class which stores info about one student. Your StudentList class should have add/remove/search methods. The add method should create a new instance of a StudentRecord object (dynamic allocation) and add it to the list. The code to ask for student details should NOT be in the StudentList class, but in the main and then passed to the add method.

Also, a menu-driven system should have a loop, otherwise you can only do one operation.

You can't have a function that has the same name of your class, how can you tell what's what?
You have some code outside the main function or any other functions, that doesn't seem right.

Hope this helps ^^ :)

thank you guy's thats helped

i did most of the codes exept when i create the link list and stored them it dose not save them alphabeticallly by last name , and when editing i confused alot of stuff i dont know how to search for them by last name and edit one of them like for example change their grade. Can you guys help me :)

this is the code

#include <iostream> 

using namespace std; 

#define SIZE 100 


struct student_list 
{ 
    char First_name [SIZE]; 
    char Last_name [SIZE]; 
    int ID; 
    float mid_grade,final_grade;  
    student_list *next; // pointer to next link 
}; 
student_list *head=NULL; 
student_list *current;
int option =0;

void enter_student (){

     student_list *temp,*start;
     temp = new student_list; // dynamiclly allocationg  

     cout << "Enter student first name "<<endl; 
     cin >> temp-> First_name; 
     cout << "Enter student last name "<<endl; 
     cin>> temp-> Last_name; 
     cout<< "please enter student ID "<<endl; 
     cin>>temp->ID; 
     cout<<"please enter midterm grade"<<endl; 
     cin>> temp->mid_grade; 
     cout<<"please enter final grade"<<endl; 
     cin>> temp->final_grade; 
     temp -> next = NULL;

     if (head == NULL ){
         head = temp;
         current = head;
     }
     else {
         start=head;
         while (start ->next !=NULL){
             start=start->next;
         }
         start->next=temp;
     }
}

void display_lists(){
    student_list *temp;
    temp=head;
    cout<<endl;
    if(temp==NULL)
        cout<<"you didnt enter any thing at all!! your list is empty"<<endl<<endl;

    else{

        while(temp !=NULL){
            cout<<"student name: "<<temp->Last_name;
            cout<<","<<temp-> First_name<<endl;
            cout<<"ID number: "<<temp->ID<<endl;
            cout<<"first midterm grade: "<<temp->mid_grade<<endl;
            cout<<"final exam grade: "<<temp->final_grade<<endl<<endl;
            temp = temp -> next;
        }
        cout<< "LIST ENDED !"<<endl;
    }
}

void edit(){
    student_list *temp,*y;
    int strcmp(char *name1,char *name2);

    temp = head;
    head = head -> next;
    cout<<"enter student last name please: "<<endl;
    cin>>name1-;
    name2=name2->next;

    if (name1 = name2){
        return 0;
    }
    else if ( name1>name2){
        return >0;
    }
    else if (name2>name1){
        retun <0;
    }
    if(strcmp(y->name1,temp->name1)==0)
}

int main () 
{ 

    head = NULL;
    while ( option != 4){

        cout <<"Welcome to bos3ayed C++ writer company "<<endl; 
        cout << " this program help you to orginzing your student information"; 
        cout<<". first name , last name , ID, first midterm grade, and final"<<endl; 
        cout <<endl<<endl; 
        cout<< "Choose what do you want to do from this menu (1,2,3,4)"<<endl; 
        cout<<"1) Enter new student"<<endl; 
        cout<<"2) Edit existing student ( serch by name)"<<endl; 
        cout<<"3) Display list "<<endl; 
        cout<<"4) Exit"<<endl; 
        cin>> option;

        switch (option){
            case 1 : enter_student();
                break;
            case 3 : display_lists();
                break;
            case 2 : edit ();
                break;


             } 
}
return 0;
system("pause");
}

thanks in advance,

Edited 3 Years Ago by pyTony: fixed formatting

Please use code tags when posting code, preferably the language-specific version so we get syntax highlighting. It makes the code MUCH easier to read.

If you want the linked list to be ordered by last name, the convention is to put the record in the list where it belongs.

If the first record added is for "James Smith" then it is the only record. If we now want to add a record for "Bill Wilson", it should be added after "James Smith". If we then add a record for "Carol Fisher" if goes before "James Smith". Repeat as additional records are added and the list will always be sorted by last name.

So the code ends up looking something like:

// preinitialize the new record's next to null
newstudent -> next = null;

student_list * prev = null;
student_list * curr = head;
// while there are more records to look at on the list
while (curr != null)
{
   // should the new record come before the 'current' record in the list?
   if (strcmp(newstudent -> Last_Name, curr -> Last_Name) < 0)
   {
      newstudent -> next = curr;
      break
   }
   prev = curr;
   curr = prev -> next;
}

if (prev == null)
   head = newstudent
else
   prev -> next = newstudent
Comments
Better copy/paste the "please use tags" phrase to a hot key, you need it a lot at DW

thank you i did the alphabetical order . now i am trying to edition one of the link list that i created like for example changing the name or grade or id.
this is the code

#include <iostream> 
#include < stdlib.h>
using namespace std; 
#define SIZE 100 

class student_list 
{ 
public:
	char First_name [SIZE]; 
    char Last_name [SIZE]; 
    int ID; 
    float mid_grade,final_grade;  
    student_list *next; // pointer to next link 
}; 

student_list *head=NULL; 
student_list *current;
int option =0;

void enter_student (){
 
     student_list *temp,*ptr,*front,*back;
     temp = new student_list; // dynamiclly allocationg       
	 cout << "Enter student first name "<<endl; 
     cin >> temp-> First_name; 
     cout << "Enter student last name "<<endl; 
     cin>> temp-> Last_name; 
     cout<< "please enter student ID "<<endl; 
     cin>>temp->ID; 
     cout<<"please enter midterm grade"<<endl; 
     cin>> temp->mid_grade; 
     cout<<"please enter final grade"<<endl; 
     cin>> temp->final_grade; 
	 temp -> next = NULL;

	 if (head == NULL ){
		 head = temp;
		
	 }
	 else {
		 
		 front=head;
		 if (front->Last_name > temp->Last_name){

			head=temp;
			temp->next=front;
		 }
		 else
			 while ( front->Last_name < temp->Last_name){
				 back=front;
				 front=front->next;
			 }

		 }
		 
	 }


void display_lists(){
	student_list *temp;
	temp=head;
	cout<<endl;
	if(temp==NULL)
		cout<<"list is empty!"<<endl<<endl;

	else{
	
		while(temp !=NULL){
			cout<<"student name: "<<temp->Last_name;
			cout<<","<<temp-> First_name<<endl;
			cout<<"ID number: "<<temp->ID<<endl;
			cout<<"first midterm grade: "<<temp->mid_grade<<endl;
			cout<<"final exam grade: "<<temp->final_grade<<endl<<endl;
			temp = temp -> next;
		}
		cout<< "LIST ENDED !"<<endl;
	}
}

void edit(){

     char edit[SIZE];
     student_list *temp;
	 cout<<"please enter the student last name"<<endl;
	 cin>> edit;
	
	 while (edit,temp!=NULL){
          if (stcmp(
          cout<<"enter new student first name"<<endl;
          cin>> temp->First_name;
          cout<<"enter new student last name"<<endl;
          cin>>temp->Last_name;
          cout<<"enter new student ID"<<endl;
          cin>>temp->ID;
          cout>>"enter new first midterm grade"<<endl;
          cin<<temp->mid_grade;
          cout"enter new final grade"<<endl;
          cin>>temp->final_grade;
	
}

int main () 

{ 
  
	head = NULL;
	cout <<"Welcome to bos3ayed C++ writer company "<<endl; 
	cout << " this program help you to orginzing your student information"; 
	cout<<". first name , last name , ID, first midterm grade, and final"<<endl; 
	cout <<endl<<endl; 
	while ( option != 4){
		cout<< "Choose what do you want to do from this menu (1,2,3,4)"<<endl; 
		cout<<"1) Enter new student"<<endl; 
		cout<<"2) Edit existing student ( serch by name)"<<endl; 
		cout<<"3) Display list "<<endl; 
		cout<<"4) Exit"<<endl; 
		cin>> option;
	
		switch (option){
			case 1 : enter_student();
				break;
			case 3 : display_lists();
				break;
			case 2: edit();
				break;



			 } 
}
return 0;
system("pause");
}

---------------------------------------
thanks in advance

Name search: You start at the head and while there are still entries on the list, you compare the names. If they match, you found it. (if the list is still in alphabetical order, you can stop when you find a name > than the one you're looking for.)

ID search: You start at the head and while there are still entries on the list, you compare the IDs. If they match, you found it.

Once you have found it, you need to be careful about the updates. It is usually best form to remove the one you found, update it and re-add it. (Because if the field that specifies the list order changes, you need to re-position the record in the list.)

I haven't seen any excutive-able code in the main( )
and you should declear when to exit the prog . i think , lucky……

This question has already been answered. Start a new discussion instead.