Alice is trying to monitor how much time she spends studying per week. She going through her logs, and wants to figure out which week she studied the least, her total time spent studying, and her average time spent studying per week. To help Alice work towards this goal, write three functions: min(), total(), and average(). All three functions take two parameters: an array of doubles and the number of elements in the array. Then, they make the following computations:
min() - returns the minimum value in the array
sum() - returns the sum of all the values in the array
average() - returns the average of all the values in the array
You may assume that the array will be non-empty.
Function specifications:
Function 1: Finding the minimum hours studied
Name: min()
Parameters (Your function should accept these parameters IN THIS ORDER):
arr double: The input array containing Alice's study hours per week
arr_size int: The number of elements stored in the array
Return Value: double: The minimum value in the array
Function 2: Computing the total hours studied
Name: sum()
Parameters (Your function should accept these parameters IN THIS ORDER):
arr double: The input array containing Alice's study hours per week
arr_size int: The number of elements stored in the array
Return Value: double: The sum of all the values in the array
Function 3: Computing the median study hours
Name: average()
Parameters (Your function should accept these parameters IN THIS ORDER):
arr double: The input array containing Alice's study hours per week
arr_size int: The number of elements stored in the array
Return Value: double: The average of all the values in the array
Sample run 1:
Transcribed Image Text:Alice is trying to monitor how much time she spends studying per week. She's going through her logs and wants to figure out which week she studied the least, her total time spent studying, and her average time spent studying per week. To help Alice work towards this goal, we write three functions: `min()`, `total()`, and `average()`. All three functions take two parameters: an array of doubles and the number of elements in the array. Then, they make the following computations:
- **min()** - returns the minimum value in the array
- **sum()** - returns the sum of all the values in the array
- **average()** - returns the average of all the values in the array
You may assume that the array will be non-empty.
### Function specifications:
#### Function 1: Finding the minimum hours studied
- **Name:** min()
- **Parameters (Your function should accept these parameters IN THIS ORDER):**
- `arr` (`double`): The input array containing Alice's study hours per week
- `arr_size` (`int`): The number of elements stored in the array
- **Return Value:** `double`: The minimum value in the array
#### Function 2: Computing the total hours studied
- **Name:** sum()
- **Parameters (Your function should accept these parameters IN THIS ORDER):**
- `arr` (`double`): The input array containing Alice's study hours per week
- `arr_size` (`int`): The number of elements stored in the array
- **Return Value:** `double`: The sum of all the values in the array
#### Function 3: Computing the median study hours
- **Name:** average()
- **Parameters (Your function should accept these parameters IN THIS ORDER):**
- `arr` (`double`): The input array containing Alice's study hours per week
- `arr_size` (`int`): The number of elements stored in the array
- **Return Value:** `double`: The average of all the values in the array
Transcribed Image Text:```plaintext
Parameters (Your function should accept these parameters IN THIS ORDER):
- arr (double): The input array containing Alice's study hours per week.
- arr_size (int): The number of elements stored in the array.
Return Value: double: The average of all the values in the array.
Sample run 1:
Function Call:
```cpp
double arr[] = {1.24, 5.68, 3.456};
int arr_size = 3;
cout << "Min: " << fixed << setprecision(3) << min(arr, arr_size) << endl;
cout << "Sum: " << fixed << setprecision(3) << sum(arr, arr_size) << endl;
cout << "Avg: " << fixed << setprecision(3) << average(arr, arr_size) << endl;
```
Output:
```
Min: 1.240
Sum: 10.376
Avg: 3.459
```
Sample run 2:
Function Call:
```cpp
double arr[] = {0};
int arr_size = 1;
cout << "Min: " << fixed << setprecision(3) << min(arr, arr_size) << endl;
cout << "Sum: " << fixed << setprecision(3) << sum(arr, arr_size) << endl;
cout << "Avg: " << fixed << setprecision(3) << average(arr, arr_size) << endl;
```
Output:
```
Min: 0.000
Sum: 0.000
Avg: 0.000
```
```
Expert Solution
This question has been solved!
Explore an expertly crafted, step-by-step solution for a thorough understanding of key concepts.
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.