# CST 280 In-Class Practice – Week 3 A and B - 74832

Solution Posted by

Rating : (19)A+
Solution Detail
Price: \$10.00
Request Description

CST 280 In-Class Practice – Week 3

Access the following files from the list of examples within the course web materials:

source file partMgr.cpp

data file partList.txt

Create a project file using the C++ development tool in the classroom and store the files in the project.

This algorithm manages a list of parts including attributes such as part number, part name, weight, and price. The system is complete except for the functions that will insert a new part into the list and delete an existing part from the list.

Currently, the list of records is managed as an unordered list. A much longer list might be anticipated and the functions for inserting and deleting a new record must be modified. Redesign the functions that currently insert and delete records so that the list remains ordered. You should also edit the initial file to sort it ascending by part number to be sure your algorithms start properly.

The algorithm for inserting and deleting into a list of ordered integers are below:

void OrdListInsert(int list[], int& numElems, int newint)

{

int ptr = 0;

while (newint > list[ptr] && ptr < numElems)

ptr++;

for (int i = numElems; i > ptr; i--)

list[i] = list[i-1];

list[ptr] = newint;

numElems++;

}

void OrdListDelete(int list[], int& numElems, int oldint)

{

// Locate item to delete

int ptr = 0;

while (oldint != list[ptr] && ptr < numElems)

ptr++;

// Move all successors up one position - deleting target value

for (int i = ptr; i < numElems - 1; i++)

list[i] = list[i+1];

// Adjust number of elements in list

numElems--;

}

Deliverables: Demonstrate an insert, deletion, and listing to the instructor

CST 280 In-Class Practice – Week 3

Capture the compbiled set of program files in RightTriangle.zip using code (8er6).

Decompress this set to access files:

RightTriangle.h

RightTriangle.cpp

testTriangle.cpp

Create a project file using the C++ development tool in the classroom and store the files in the project.

Next, complete the code for this problem. Add/change the following:

• Add a parameterized constructor that will accept both a base and height.

• Add a member function that will calculate the area of a right triangle (1.0/2.0 * base * height). Add a call to this function in the driver program and add the area calculation as a line of output.

• Add "get" functions to the class for both data members. Integrate use of

these functions into the output by reporting back to the user what the

triangle dimensions are.

Deliverables: Completed program source code and output.

Solution Description

CST 280 In-Class Practice – Week 3

Access the following files from the list of examples within the course web materials:

source file partMgr.cpp

data file partList.txt

Create a project file using the C++ development tool in the classroom and store the files in the project.

This algorithm manages a list of parts including attributes such as part number, part name, weight, and price. The system is complete except for the functions that will insert a new part into the list and delete an existing part from the list.

Currently, the

Attachments