Question: Task 2: in C++ Please compile & execute code in Command Prompt or Terminal / DO NOT USE IDE Please Include Snipping Photo of the

Task 2:

in C++

Please compile & execute code in Command Prompt or Terminal / DO NOT USE IDE

Please Include Snipping Photo of the Whiteboard / Pseudo Code of program below for hardcoded common algorithms

Implement a class for Task 1 and Hardcode algorithms for Linear Search, Middle Value, First Value, Last Value, Highest Value, Lowest Value, and Bubble Sort.

Main Function: Declare and fill an array with 1000 random integers between 1 - 1000.

Class will contain the methods below and an array as the data structure.

Please use comments to identify constructors and methods in the program.

Method 1:

Access each element

For {}

Output all values

Method 2:

Access each element

For {}

Sum values at each index

Output the sum of all values

Sum = 0

Sum = sum + sample[i]

Method 3:

Output all odd numbers

Odd: if(sample[i] % 2! =0)

Method 4:

Output all even numbers

Even : if (sample[i] % 2 = 0)

Method 5:

Enter a search value / Implement Linear Search

Method 6:

New

l

Output Middle Value (Values in the Middle)

Not Average

Method 7:

Output First Value in the Array

Method 8:

New

Output Last Value in the Array

Method 9:

New

Access each element

FOr {}

if(high)

Output the Highest Value and its location in the array. (Hardcode the algorithm.)

Max_value = sample[0]

If (sample[i] > max_value)

Max_value = sample[i]

Method10:

New

Access each element

FOr {}

if(low)

Output the Lowest Value and its location in the array. (Hardcode the algorithm.)

low_value = sample[0]

If (sample[i] > low_value)

low_value = sample[i]

Method 11:

New

Sort and then output values. Hardcode the bubble sort algorithm you will implement.

  • Attach a snipping photo of source code and output

  • Make sure to include photo class

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!