please help me
Write a struct NodeType with three member variables
Write a program to use a circular linked list for class TotalLinkedList with four member variables
NodeType
Name : string
Grade : int
Link : NodeType *
Your code will insert the student name and his grade then:
If the grade >= 50, insert the node at the first of pointer Pass
If the grade < 50, insert the node at the first of pointer Fail
If the grade is invalid then don’t do the insert.
TotalLinkedList
-Pass: NodeType *
-Fail: NodeType *
-CountPass : int
-CountFail: int
+ insert(string, int ) : void
+ deleteNode (int) : void
+ searchName (string) : int
+ FindMax( ): string
+PrintAverage(): double
+ print ( ) : void
+ TotalLinkedList( )
+ ~TotalLinkedList( )
+ TotalLinkedList (TotalLinkedList & )
DeleteNode(int): takes the grade and delete all the node with this grade
SearchName( string): takes the student name and return his grade if found else return -1
Print the students name and their grades
In the main function
TotalLinkedList Obj1;
Obj1.insert("Ali" , 90);
Obj1.insert("Ahmed", 44);
Obj1.insert("Ruba", 103);
Obj1.insert("Majd", 77);
Obj1.insert("Huda" , 85);
Obj1.insert("Kamel", 39);
Obj1.insert("Ola", -5);
Obj1.insert("Eman", 90);
Now Obj1.deleteNode(90);
Now...
Obj1. print( );
cout<<Obj1.searchName("Ahmad");
cout<<printAverage( ) <<endl;
cout<<findMax() <<endl;
You need to ask the user to insert the names or to read from files (I prefer the second choice)...
You need to ask the user to delete a grade...
[Edit]Code block added[/Edit]
Edit: enhzflep - Added code from comment to Paul.
#include <iostraem>
#include <string>
using namespace std;
struct NodeType
{
string Name ;
int Grade ;
NodeType* Link ;
}
class TotalLinkedList
{
private:
NodeType* Pass;
NodeType* Fail ;
int CountPass ;
int CountFail ;
public :
void insert(string , int );
void deletNode(int);
int searchName(string) ;
int FindMax (string);
double PrintAverage ();
void Print ();
TotalLinkedList();
~TotalLinkedList();
TotalLinkedList(TotalLinkedList&);
}
TotalLinkedList::insert (string name ,int grade )
{
cin >> grade ;
cin >> name ;
if ( grade >=50 )
{
Pass->Name =name ;
Pass->Grade =grade
}
else
{
Fail->Name=name;
Fail->Grade=grade;
}
else
{
cout << " can not insert " << endl;
} }
int main ()
{
return 0 ;
}