Question: Linked Lists As en entry-level programmer you have to be able to read, understand existing code and update it (add new features). This is one

Linked Lists

As en entry-level programmer you have to be able to read, understand existing code and update it (add new features). This is one of this assignments goals: read about 600 lines of code (Projects A & B), compile and run these projects, read and understand the code, then change it as required. You are encouraged to reuse as much code as possible.

Program 6B Write a function that displays students with gpa <= a given gpa as show below

 list.displayList(3.0); 

Project B: Student List // Code Review + write and test one function (Student class) Student.h, StudentList.h, StudentList.cpp, 22B_H6_B_Stu.cpp

Display the list as shown below (using the hDisplay()function):

====== ==== Code Rank ====== ==== 
 SBCC 3 DAC 1 PCC 5 

====== ====

============================= ========= Name Cost

============================= =========

Santa Barbara City College De Anza College Pasadena City College

30687 19302 22000 

============================= =========

/*

CIS 22B: Homework 6B // Student is a class

This program demonstrates the insertNode, deleteNode, getCount(), and displayList member functions.

It builds and displays a sorted list

The list is sorted by gpa

Write a function that displays students with gpa <= a given gpa as show below

list.displayList(3.0);

Run the program once and save the output as a comment at the end of this source file.

*/

#include

#include "StudentList.h"

#include "StudentList.cpp"

#include "Student.h"

using namespace std;

int main()

{

// Define a StudentList object.

StudentList list;

Student s1(3.1, "Paul");

Student s[10] =

{{2.5, "John"}, {3.9, "Linda"}, {3.6, "Bob"}, {2.7, "Ann"}, {4.0, "Mary"}, {3.2, "Andy"}};

Student s2(2.3, "Tom");

//******************************

cout << "TESTING INSERT ";

//Insert one value to the list.

cout << "\tInsert " << s1.getGpa() << " " << s1.getName() << endl;

list.insertNode(s1);

// Display the values in the list.

list.displayList();

cout << "\t\tThis list has " << list.getCount() << " student[s] ";

//Insert more values to the list

for (int i = 0; i < 6; i++)

{

cout << "\tInsert " << s[i].getGpa() << " " << s[i].getName() << endl;

list.insertNode(s[i]);

// Display the values in the list.

list.displayList();

cout << "\t\tThis list has " << list.getCount() << " student[s] ";

}

//Insert one value to the list.

cout << "\tInsert " << s2.getGpa() << " " << s2.getName() << endl;

list.insertNode(s2);

list.displayList();

int n = list.getCount();

cout << "\t\tThis list has " << n << " student[s] ";

//******************************

cout << "TESTING DISPLAY ";

list.displayList();

//list.displayList(3.0); //<====================================

//******************************

cout << "TESTING DELETE ";

// Delete the first node

cout << "\tDelete the first node ";

list.deleteNode(2.3);

list.displayList();

// Delete the last node

cout << "\tDelete the last node ";

list.deleteNode(4.0);

list.displayList();

// Delete a node in the middle

cout << "\tDelete 3.1 ";

if( list.deleteNode(3.1) )

cout << "Deleted ";

else

cout << "Target (3.1) not found ";

list.displayList();

// Try to delete an item not in the list

cout << "\tTry to delete 3.0 ";

if( list.deleteNode(3.0) )

cout << "Deleted ";

else

cout << "Target (3.0) not found ";

list.displayList();

cout << "\t\tThis list has " << list.getCount() << " student[s] ";

return 0;

}

/***************************************************************

Save the OUTPUT below

*/

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!