Question: C++ 1) Write a OOP program that can store an array of 10 Positive integers. Remember, you are creating a class with variables, an array
C++
1) Write a OOP program that can store an array of 10 Positive integers.
Remember, you are creating a class with variables, an array and functions.
Create a UML class diagram:
Sketch out what: variables, an array and functions do you need ?
Functions: isfull, isEmpty, find, delete, print all
Initialize all elements in the array to all 99999's , 99999 mean an empty array element.
Add/code one of the good sorting algorithms: BUBBLE SORT
Add/code one of the top searching algorithms: BINARY SEARCH
Have a function to ask the user for input. Hint, got to check if array is not Full, before you can add a value.
Have a function to print out the array, non 99999 values.
Have a function to delete an integer. Hint, got to find if it exists in array first, before it can over write with 99999.
Have the ability to know/printout the count the number of integers
Test:
* Enter 23, 42, 75, 104, 32, 21, 11, 49 in this order...
* Sort element in array
* Find value 42
* Try to find value 91
* Delete 32 and resort array
* Print all element in array
Note: The int main() function contents, you write for program 1, should be exactly the same as program 2.
Hint: Here is most of the code for the int main() function for BOTH prog 1 and prog 2.
Example of int main() {
className List; // use class definition and declare instance.
List.Insert(23);
List.Insert(42);
List.Insert(75);
List.Insert(104);
List.Insert(32);
List.Insert(21);
List.Insert(11);
List.Insert(49);
List.Sort(); // required in prog 1. Should not be needed in prog 2 if you do insertion sort properly.
List.PrintAll();
cout << List.Find(42) << endl;
cout << List.Find(91) << endl;
List.Delete(32);
List.Sort(); // required in prog 1. Should not be needed in prog 2 if you do insertion sort properly.
List.PrintAll();
return 0;
}
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
