
CLASS TEMPLATE - ARRAY
Arya has completely learned about function templates and using them in Arrays, her teacher has given her a task to implement class Templates for all the same things-searching, sorting, and displaying an array using templates. You are her friend and you have knowledge about class templates, help Arya to make a class template to search, sort, and display an array.
Write a C++
Strictly adhere to the Object-Oriented specifications given in the problem statement. All class names, member variable names, and function names should be the same as specified in the problem statement.
A class named Array with the following member variables.
Data Type | Variable Name |
Integer | size |
T* | array |
Define the following public functions inside the class Array.
Function Name | Description |
void sorting() | This function is used to sort the array elements in ascending order and display the array. |
void search(T &search) | This function is used to search the array element, if the element is found display "Element found at position x" else print "Element not found" |
Problem Constraint:
Use the template class to perform the operations
template <class T>
Note:
Use integer array for sorting and use an array of double values to search.
In the main method, display the menu and according to the user's choice get the size of the array from the user and create the array using the class name and call the corresponding function. If the user enters a choice other than 1 or 2 print "Invalid number"
Input and Output Format:
Refer sample input and output for formatting specifications.
[All text in bold corresponds to input and rest corresponds to output]
Sample Input and Output 1:
Menu
1.Sorting integer array
2.Searching array of double values
Enter your choice:
1
Enter size of array:
3
Enter the array elements:
5
2
55
Sorted array
2
5
55
Sample Input and Output 2:
Menu
1.Sorting integer array
2.Searching array of double values
Enter your choice:
2
Enter size of array:
3
Enter the array elements:
23.45
15.78
324.67
Enter the element to search:
15.78
Element found at position 2
Sample Input and Output 3:
Menu
1.Sorting integer array
2.Searching array of double values
Enter your choice:
2
Enter size of array:
2
Enter the array elements:
55.45
35.78
Enter the element to search:
19.28
Element not found
Sample Input and Output 4:
Menu
1.Sorting integer array
2.Searching array of double values
Enter your choice:
3
Invalid number

![PROGRAM
C++ Project
SUBMIT
P VALIDATE
O RESET
COMPILE
EXECUTE
PREVIOUS SUBMISSIONS
A Save File ( Ctrl +S)
Main.cpp/
TempArray.cpp/
1
#include<iostream>
2877_78830_8199_30
2 using namespace std;
O Main.cpp
template <class T>
5- class Array {
T *arr;
int size;
4
O TempArray.cpp
6.
7
8
9.
public:
10
Array(T a[],int size) {
[i/ fiil the code
}
11
12
13
14
void sorting() {
// fill the code
15
16
17
18
void search(T &search) {
| // fill the code
19
20
21
22
23
}
24
};
25
II](https://content.bartleby.com/qna-images/question/c199123c-f2ec-43fa-a504-6478a32f0b2c/c4df072d-f3b7-4c12-8a3d-e95ee3180cb0/w7ndp3d_thumbnail.png)

Trending nowThis is a popular solution!
Step by stepSolved in 2 steps

- This is warning you, don't use any AI platform to generate answer.arrow_forwardC++ In this lab, you're going to be working with partially filled arrays that are parallel with each other. That means that the row index in multiple arrays identifies different pieces of data for the same person. This is a simple payroll system that just calculates gross pay given a set of employees, hours worked for the week and hourly rate. Parallel Arrays First, you have to define several arrays in your main program: employee names for each employee hourly pay rate for each employee total hours worked for each employee gross pay for each employee You can use a global SIZE of 50 to initialize these arrays. Second, you will need a two dimension (2-D) array to record the hours worked each day for an employee. The number of rows for the 2-D array should be the same as the arrays above since each row corresponds to an employee. The number of columns represents days of the week (7 last I looked). Functions Needed In this lab, you must read in the employee names first because this…arrow_forwardC++ ONLY PLEASE, and please read carefully, i have had people submit wrong answers Assignment 7 A: Rare Collection. We can make arrays of custom objects just like we’ve done with ints and strings. While it’s possible to make both 1D and 2D arrays of objects (and more), for this assignment we’ll start you out with just one dimensional arrays. Your parents have asked you to develop a program to help them organize the collection of rare CDs they currently have sitting in their car’s glove box. To do this, you will first create an AudioCD class. It should have the following private attributes. String cdTitle String[4] artists int releaseYear String genre float condition Your class should also have the following methods: Default Constructor: Initializes the five attributes to the following default values: ◦ cdTitle = “” ◦ artists = {“”, “”, “”, “”} ◦ releaseYear = 1980 ◦ genre = “” ◦ condition = 0.0 Overloaded Constructor: Initializes the five attributes based on values passed…arrow_forward
- Write in C++ 1. Define a struct for a soccer player that stores their name, jersey number, and total points scored. 2.Using the struct in #1, write a function that takes an array of soccer players and its size as arguments and returns the average number of points scored by the players. 3.Using the struct in #1, write a function that takes an array of soccer players and its size as arguments and returns the index of the player who scored the most points. 4.Using the struct in #1, write a function that sorts an array of soccer players by name. 5.Using the struct in #1, write a function that takes an (unsorted) array of soccer players and its size and a number as arguments, and returns the name of the soccer player with that number. It should not do any extra unnecessary work. 6.Define a function to find a given target value in an array, but use pointer notation rather than array notation whenever possible. 7.Write a swap function, that swaps the values of two variables in main, but use…arrow_forwarduse c++ Programming language Write a program that creates a two dimensional array initialized with test data. Use any data type you wish . The program should have following functions: .getAverage: This function should accept a two dimensional array as its argument and return the average of each row (each student have their average) and each column (class test average) all the values in the array. .getRowTotal: This function should accept a two dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a row in the array. The function should return the total of the values in the specified row. .getColumnTotal: This function should accept a two dimensional array as its first argument and an integer as its second argument. The second argument should be the subscript of a column in the array. The function should return the total of the values in the specified column. .getHighestInRow: This function should accept a two…arrow_forwardC++ HELP In this lab, you're going to be working with partially filled arrays that are parallel with each other. That means that the row index in multiple arrays identifies different pieces of data for the same person. This is a simple payroll system that just calculates gross pay given a set of employees, hours worked for the week and hourly rate. Parallel Arrays First, you have to define several arrays in your main program employee names for each employee hourly pay rate for each employee total hours worked for each employee gross pay for each employee You can use a global SIZE of 50 to initialize these arrays Second, you will need a two dimension (2-D) array to record the hours worked each day for an employee. The number of rows for the 2-D array should be the same as the arrays above since each row corresponds to an employee. The number of columns represents days of the week (7 last I looked) Functions Needed In this lab, you must read in the employee names first because this…arrow_forward
- In C++ please follow the instructions Write two code blocks -- one code block to declare a bag and its companion type-tracking array (both using the STL vector), and another code block to create and declare a Cat object and put it into the bag. Name the arrays and variables as you wish. Use any data type tracking and any designation for cats -- your choices. Assume that struct Cat is already defined and that all required libraries are properly included -- just write the two separate code blocks, separated by one or more blank lines.arrow_forwardC++ Question Hello Please answer the attached C++ programming question correctly, just as the prompt states. Also, make sure that the code is working properly. Thank you.arrow_forwardC++ Language Please add an execution chart for this code like the example below. I have provided the code and the example execution chart. : JUST NEED EXECUTION CHARTTT. Thanks Sample Execution Chart Template//your header files// constant size of the array// declare an array of BankAccount objects called accountsArray of size =SIZE// comments for other declarations with variable names etc and their functionality// function prototypes// method to fill array from file, details of input and output values and purpose of functionvoid fillArray (ifstream &input,BankAccount accountsArray[]);// method to find the largest account using balance as keyint largest(BankAccount accountsArray[]);// method to find the smallest account using balance as keyint smallest(BankAccount accountsArray[]);// method to display all elements of the accounts arrayvoid printArray(BankAccount accountsArray[]);int main() {// function calls come here:// give the function call and a comment about the purpose,//…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





