please guy's i need help ASAP with my c++ assignmnet

Please support our C++ advertiser: Intel Parallel Studio Home
Thread Solved

Join Date: Dec 2008
Posts: 4
Reputation: q8y_4u is an unknown quantity at this point 
Solved Threads: 0
q8y_4u q8y_4u is offline Offline
Newbie Poster

please guy's i need help ASAP with my c++ assignmnet

 
0
  #1
Dec 8th, 2008
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

  1. #include <iostream>
  2. #include <string>
  3. #include <cstdlib>
  4. using namespace std;
  5.  
  6. #define SIZE 100
  7.  
  8. char ans;
  9.  
  10. int main ()
  11. {
  12.  
  13. cout <<" Welcome to bos3ayed C++ writer company "<<endl;
  14. cout << " this program help you to orginzing your student information";
  15. cout<<". first name , last name , ID, first midterm grade, and final"<<endl;
  16. cout <<endl<<endl;
  17. cout<< "Choose what do you want to do from this menu (a,b,c,d)"<<endl;
  18. cout<<"a) Enter new student"<<endl;
  19. cout<<"b) Edit existing student ( serch by name)"<<endl;
  20. cout<<"c) Display list "<<endl;
  21. cout<<"d) Exit"<<endl;
  22. cin>> ans;
  23.  
  24. }
  25.  
  26. class student_list
  27. {
  28. private:
  29. char First_name [SIZE];
  30. char Last_name [SIZE];
  31. int ID;
  32. float mid_grade,final_grade;
  33.  
  34. public:
  35. student_list *next;
  36. };
  37.  
  38. student_list::student_list() {
  39. student_list *temp , *head;
  40. temp = new student_list; // dynamiclly allocationg
  41. temp -> next = NULL;
  42. cout << "Enter student first name "<<endl;
  43. cin >> temp-> First_name;
  44. cout << "Enter student last name "<<endl;
  45. cin>> temp-> Last_name;
  46. cout<< "please enter student ID "<<endl;
  47. cin>>temp->ID;
  48. cout<<"please enter midterm grade"<<endl;
  49. cin>> temp->mid_grade;
  50. cout<<"please enter final grade"<<endl;
  51. cin>> temp->final_grade;
  52. }
  53.  
  54. student_list *head,*ptr,*tmp;
  55. head=NULL;
  56.  
  57. while () {
  58.  
  59. ptr=new student_list;
  60. temp=head;
  61. head=ptr;
  62. head->next=tmp;
  63.  
  64. }
----------------------------
thanks in advance;
Last edited by Ancient Dragon; Dec 8th, 2008 at 9:58 pm. Reason: add code tags
Reply With Quote Quick reply to this message  
Join Date: Aug 2008
Posts: 77
Reputation: mahlerfive is an unknown quantity at this point 
Solved Threads: 16
mahlerfive mahlerfive is offline Offline
Junior Poster in Training

Re: please guy's i need help ASAP with my c++ assignmnet

 
0
  #2
Dec 8th, 2008
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.
Reply With Quote Quick reply to this message  
Join Date: Nov 2008
Posts: 91
Reputation: brechtjah is an unknown quantity at this point 
Solved Threads: 9
brechtjah's Avatar
brechtjah brechtjah is offline Offline
Junior Poster in Training

Re: please guy's i need help ASAP with my c++ assignmnet

 
0
  #3
Dec 8th, 2008
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 ^^
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 4
Reputation: q8y_4u is an unknown quantity at this point 
Solved Threads: 0
q8y_4u q8y_4u is offline Offline
Newbie Poster

Re: please guy's i need help ASAP with my c++ assignmnet

 
0
  #4
Dec 11th, 2008
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,
Last edited by q8y_4u; Dec 11th, 2008 at 7:16 am.
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 538
Reputation: Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough 
Solved Threads: 86
Murtan Murtan is offline Offline
Posting Pro

Re: please guy's i need help ASAP with my c++ assignmnet

 
1
  #5
Dec 11th, 2008
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:
  1. // preinitialize the new record's next to null
  2. newstudent -> next = null;
  3.  
  4. student_list * prev = null;
  5. student_list * curr = head;
  6. // while there are more records to look at on the list
  7. while (curr != null)
  8. {
  9. // should the new record come before the 'current' record in the list?
  10. if (strcmp(newstudent -> Last_Name, curr -> Last_Name) < 0)
  11. {
  12. newstudent -> next = curr;
  13. break
  14. }
  15. prev = curr;
  16. curr = prev -> next;
  17. }
  18.  
  19. if (prev == null)
  20. head = newstudent
  21. else
  22. prev -> next = newstudent
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 4
Reputation: q8y_4u is an unknown quantity at this point 
Solved Threads: 0
q8y_4u q8y_4u is offline Offline
Newbie Poster

Re: please guy's i need help ASAP with my c++ assignmnet

 
0
  #6
Dec 11th, 2008
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



  1. #include <iostream>
  2. #include < stdlib.h>
  3. using namespace std;
  4. #define SIZE 100
  5.  
  6. class student_list
  7. {
  8. public:
  9. char First_name [SIZE];
  10. char Last_name [SIZE];
  11. int ID;
  12. float mid_grade,final_grade;
  13. student_list *next; // pointer to next link
  14. };
  15.  
  16. student_list *head=NULL;
  17. student_list *current;
  18. int option =0;
  19.  
  20. void enter_student (){
  21.  
  22. student_list *temp,*ptr,*front,*back;
  23. temp = new student_list; // dynamiclly allocationg
  24. cout << "Enter student first name "<<endl;
  25. cin >> temp-> First_name;
  26. cout << "Enter student last name "<<endl;
  27. cin>> temp-> Last_name;
  28. cout<< "please enter student ID "<<endl;
  29. cin>>temp->ID;
  30. cout<<"please enter midterm grade"<<endl;
  31. cin>> temp->mid_grade;
  32. cout<<"please enter final grade"<<endl;
  33. cin>> temp->final_grade;
  34. temp -> next = NULL;
  35.  
  36. if (head == NULL ){
  37. head = temp;
  38.  
  39. }
  40. else {
  41.  
  42. front=head;
  43. if (front->Last_name > temp->Last_name){
  44.  
  45. head=temp;
  46. temp->next=front;
  47. }
  48. else
  49. while ( front->Last_name < temp->Last_name){
  50. back=front;
  51. front=front->next;
  52. }
  53.  
  54. }
  55.  
  56. }
  57.  
  58.  
  59. void display_lists(){
  60. student_list *temp;
  61. temp=head;
  62. cout<<endl;
  63. if(temp==NULL)
  64. cout<<"list is empty!"<<endl<<endl;
  65.  
  66. else{
  67.  
  68. while(temp !=NULL){
  69. cout<<"student name: "<<temp->Last_name;
  70. cout<<","<<temp-> First_name<<endl;
  71. cout<<"ID number: "<<temp->ID<<endl;
  72. cout<<"first midterm grade: "<<temp->mid_grade<<endl;
  73. cout<<"final exam grade: "<<temp->final_grade<<endl<<endl;
  74. temp = temp -> next;
  75. }
  76. cout<< "LIST ENDED !"<<endl;
  77. }
  78. }
  79.  
  80. void edit(){
  81.  
  82. char edit[SIZE];
  83. student_list *temp;
  84. cout<<"please enter the student last name"<<endl;
  85. cin>> edit;
  86.  
  87. while (edit,temp!=NULL){
  88. if (stcmp(
  89. cout<<"enter new student first name"<<endl;
  90. cin>> temp->First_name;
  91. cout<<"enter new student last name"<<endl;
  92. cin>>temp->Last_name;
  93. cout<<"enter new student ID"<<endl;
  94. cin>>temp->ID;
  95. cout>>"enter new first midterm grade"<<endl;
  96. cin<<temp->mid_grade;
  97. cout"enter new final grade"<<endl;
  98. cin>>temp->final_grade;
  99.  
  100. }
  101.  
  102. int main ()
  103.  
  104. {
  105.  
  106. head = NULL;
  107. cout <<"Welcome to bos3ayed C++ writer company "<<endl;
  108. cout << " this program help you to orginzing your student information";
  109. cout<<". first name , last name , ID, first midterm grade, and final"<<endl;
  110. cout <<endl<<endl;
  111. while ( option != 4){
  112. cout<< "Choose what do you want to do from this menu (1,2,3,4)"<<endl;
  113. cout<<"1) Enter new student"<<endl;
  114. cout<<"2) Edit existing student ( serch by name)"<<endl;
  115. cout<<"3) Display list "<<endl;
  116. cout<<"4) Exit"<<endl;
  117. cin>> option;
  118.  
  119. switch (option){
  120. case 1 : enter_student();
  121. break;
  122. case 3 : display_lists();
  123. break;
  124. case 2: edit();
  125. break;
  126.  
  127.  
  128.  
  129. }
  130. }
  131. return 0;
  132. system("pause");
  133. }

---------------------------------------
thanks in advance
Reply With Quote Quick reply to this message  
Join Date: May 2008
Posts: 538
Reputation: Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough Murtan is a jewel in the rough 
Solved Threads: 86
Murtan Murtan is offline Offline
Posting Pro

Re: please guy's i need help ASAP with my c++ assignmnet

 
0
  #7
Dec 11th, 2008
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.)
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 4
Reputation: q8y_4u is an unknown quantity at this point 
Solved Threads: 0
q8y_4u q8y_4u is offline Offline
Newbie Poster

Re: please guy's i need help ASAP with my c++ assignmnet

 
0
  #8
Dec 13th, 2008
thank youuuuuu veeeeeeeeeeeery much i finished it
Reply With Quote Quick reply to this message  
Join Date: Dec 2008
Posts: 17
Reputation: AHUazhu is an unknown quantity at this point 
Solved Threads: 2
AHUazhu AHUazhu is offline Offline
Newbie Poster

Re: please guy's i need help ASAP with my c++ assignmnet

 
0
  #9
Dec 13th, 2008
I haven't seen any excutive-able code in the main( )
and you should declear when to exit the prog . i think , lucky……
Reply With Quote Quick reply to this message  
Reply

This thread has been marked solved.
Perhaps start a new thread instead?
Message:


Thread Tools Search this Thread



About Us | Contact Us | Advertise | DaniWeb | Acceptable Use Policy | RSS Feed

©2003 - 2009 DaniWeb® LLC