Coding Practice¶

There are errors in the code below. Modify the code so that main runs successfully. Select the Parsonsprob tab for hints for the construction of the code.

There are errors in the code below. Modify the code so that main runs successfully. Use the lines to construct the code, then go back to complete the Activecode tab.

In main create a Temp object to calculate what 100 degrees Celsius is in Fahrenheit. Select the Parsonsprob tab for hints for the construction of the code.

In main create a Temp object to calculate what 100 degrees Celsius is in Fahrenheit. Use the lines to construct the code, then go back to complete the Activecode tab.

What if we had an existing vector with data that we want to copy into our MyVector? Write a constructor that takes a vector and copies the data into the elements vector. Select the Parsonsprob tab for hints for the construction of the code.

What if we had an existing vector with data that we want to copy into our MyVector? Write a constructor that takes a vector and copies the data into the elements vector. Use the lines to construct the code, then go back to complete the Activecode tab.

Now we can write some of our own fun functions! No longer do we need to write for loops every time we want to print out a vector. With MyVector, we can just call the member function print! Write the MyVector member function print, which prints out the contents of MyVector. For example, if our MyVector contained the elements 2, 5, 1, and 8, print should print out [2, 5, 1, 8] followed by a newline. Select the Parsonsprob tab for hints for the construction of the code.

Now we can write some of our own fun functions! No longer do we need to write for loops every time we want to print out a vector. With MyVector, we can just call the member function print! Write the MyVector member function print, which prints out the contents of MyVector. For example, if our MyVector contained the elements 2, 5, 1, and 8, print should print out [2, 5, 1, 8] followed by a newline. Use the lines to construct the code, then go back to complete the Activecode tab.

What if we wanted to return the largest and smallest elements in our MyVector? Write the public member functions max and min which calls the private member functions findMax and findMin. findMax and findMin return the indices of the max and min values, and max and min call these private member functions and return the max and min values. Select the Parsonsprob tab for hints for the construction of the code.

What if we wanted to return the largest and smallest elements in our MyVector? Write the public member functions max and min which calls the private member functions findMax and findMin. findMax and findMin return the indices of the max and min values, and max and min call these private member functions and return the max and min values. Use the lines to construct the code, then go back to complete the Activecode tab. Be sure to declare the max and min functions in public when you complete the Activecode.