Question: ***I need help editing and fixing this program, When you input the students name for example John Doe and then you ask to display the
***I need help editing and fixing this program, When you input the students name for example "John Doe" and then you ask to display the name it only displays the first name. Second when I try to modify the students info it does nothing. And last when i delete the student info and then i display it, it still shows the gpa and id number, i need that fixed as well to delete everything.***
#include #include #include using namespace std; bool check = true; struct node { char name[20]; int idNum; float gpa;
node *next; }*head,*lastptr; void Display(){ cout<<"linked list data is:"<idNum<<" "<name<<" "<gpa<next!=NULL) cout<<"==>"; temp=temp->next; } }
void Add() //Add Student's Info// { node *p; p=new node; cout<<"Enter name of student:"<>p->name; fflush(stdin); cout<<"Enter Id Number of student:"<>p->idNum; fflush(stdin); cout<<"Enter GPA of student:"<>p->gpa; fflush(stdin); p->next=NULL;
if(check) { head = p; lastptr = p; check = false; } else { lastptr->next=p; lastptr=p; } cout<>id_Num; prev=head; current=head; while(current->idNum!=id_Num) { prev=current; current=current->next; } ptr=new node; fflush(stdin); cout<<"Enter name of student:"<name); fflush(stdin); cout<<"Enter ID number of student:"<>ptr->idNum; fflush(stdin); cout<<"Enter GPA of student:"<>ptr->gpa; fflush(stdin); prev->next=ptr; ptr->next=current->next; current->next=NULL; delete current; cout<>id_Num; prev=head; current=head; while(current->idNum!=id_Num) { prev=current; current=current->next; } cout<<" name: "; cout<name; cout<<" ID number:"; cout<idNum; cout<<" GPA:"; cout<gpa; getch(); } void Delete() //Deletes Student's Info// { node *ptr=NULL; node *prev=NULL; node *current=NULL; int id_Num; cout<<"Enter ID Number to Delete:"<>id_Num; prev=head; current=head; while(current->idNum!=id_Num) { prev=current; current=current->next; } prev->next = current->next; current->next=NULL; delete current; cout< int main() { int choice; do { cout<<"Option: "<>choice; cout<