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++ program to create a class template using an array. Perform operations like sorting, searching, and displaying the array using a class template.   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   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

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

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++ program to create a class template using an array. Perform operations like sorting, searching, and displaying the array using a class template.

 

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

 

 

Expert Solution
steps

Step by step

Solved in 3 steps

Blurred answer
Knowledge Booster
Reference Types in Function
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education