Database System Concepts
Database System Concepts
7th Edition
ISBN: 9780078022159
Author: Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher: McGraw-Hill Education
Bartleby Related Questions Icon

Related questions

Question

Write in C++

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:

[画像: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]
expand button
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
[画像:```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 ``` ``` ]
expand button
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
Check Mark
Knowledge Booster
Background pattern image
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
    Text book image
    Database System Concepts
    Computer Science
    ISBN:9780078022159
    Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
    Publisher:McGraw-Hill Education
    Text book image
    Starting Out with Python (4th Edition)
    Computer Science
    ISBN:9780134444321
    Author:Tony Gaddis
    Publisher:PEARSON
    Text book image
    Digital Fundamentals (11th Edition)
    Computer Science
    ISBN:9780132737968
    Author:Thomas L. Floyd
    Publisher:PEARSON
    Text book image
    C How to Program (8th Edition)
    Computer Science
    ISBN:9780133976892
    Author:Paul J. Deitel, Harvey Deitel
    Publisher:PEARSON
    Text book image
    Database Systems: Design, Implementation, & Manag...
    Computer Science
    ISBN:9781337627900
    Author:Carlos Coronel, Steven Morris
    Publisher:Cengage Learning
    Text book image
    Programmable Logic Controllers
    Computer Science
    ISBN:9780073373843
    Author:Frank D. Petruzella
    Publisher:McGraw-Hill Education