Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1. Using the linked list program given in class , alter the program to input twe

ID: 3766303 • Letter: 1

Question

   1. Using the linked list program given in class , alter the

   program to input twenty five FLOATS , sorting them

   as they are inserted into the list. Print out

   the sorted list.

   2. Create a linked lists with two info fields, a last name

   and a G.P.A. (Ex. Smith, 3.98) Sort the list as it is

   created, by G.P.A. (use 1.) Print out list.

       Then, delete all entries whose G.P.A. is

       less than 2.5. Print out the new list

       Finally, create a new list out of this modified

       list , this time sorting alphabetically

C++ Please!

#include <iostream>

using namespace std;

void getdata(int& ident,int& grade_value);

const int nil = 0;

class node_type          // declaration of class//

{

public:

       int id;

       int grade;

       node_type *next;

};

void main()

{

   node_type *first,*p,*q,*newnode;

   int i,ident,grade_value;

   float sum,average;

   sum = 0;

   first = new node_type;

   p = first;

   getdata(ident,grade_value);

   (*first).id = ident;

   (*first).grade = grade_value;

   (*first).next = nil;

    for (i =2; i<=10;++i)

   {

      getdata(ident,grade_value);

       newnode = new node_type;

       (*newnode).id = ident;

       (*newnode).grade = grade_value;

       (*newnode).next = nil;

//**********Links previous node to newnode******//

       (*p).next = newnode;

       p = newnode;

   }

//**********Traverses list and prints out nodes in chronological order ******//

       q = first;

       cout << "The list contains ";

       while (q != nil)

       {

           cout << "ID is :" << (*q).id << " ";

           cout << "GRADE is :" << (*q).grade << " ";

           sum = sum + (*q).grade;

           q = (*q).next;

       }

       average = sum/10;

       cout << " The average of the grades is " << average << " ";

}

void getdata(int& ident,int& grade_value)

{

   cout << "Enter id and grade " ;

   cin >> ident;

   cout << ident << " ";

   cin >> grade_value;

   cout << grade_value << " ";

}

Explanation / Answer

#include using namespace std; void getdata(int& ident, int& grade_value); const int nil = 0; class node_type // declaration of class// { public: int id; int grade; node_type *next; }; void main() { node_type *first, *p, *q, *newnode; int i, ident, grade_value; float sum, average; sum = 0; first = new node_type; p = first; getdata(ident, grade_value); (*first).id = ident; (*first).grade = grade_value; (*first).next = nil; for (i = 2; i