Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include #include // Declare Global variables here. void array_stats() { // Insert your solution here. } #include #include int main() { // Simulate the

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

#include #include #include

// Declare Global variables here.

void array_stats() { // Insert your solution here. }

#include #include

int main() { // Simulate the test setup process. srand( time( NULL ) ); for ( int i = 0; i

// Call submitted code. array_stats();

// Display contents of array val. for (int i = 0; i

printf(" "); printf("Item count: %d ", val_count); printf("Item mean : %f ", val_mean); printf("Item min : %f ", val_min); printf("Item max : %f ", val_max);

return 0; }

. Global variables: o val: an array with capacity to hold 25 values of type double o val count: an int which is used to remember how many values have been scanned. val_mean: a double precision floating point value which is used to store the mean of the items which have been scanned. val_min: a double precision floating point value which is used to store the minimum of the items which have been scanned. val_max: a double precision floating point value which is used to store the maximum of the items which have been scanned. Parameters o array_stats expects no arguments .Returns: o array_stats produces no result (i.e. the return type is void) e Process: The program should follow the algorithm of introduced in a previous formative exercise to fetch the input data and save it in the array o Where the earlier exercise computed the sum of the input values, this program will be adapted to compute the arithmetic mean of the input values o In addition to the mean, calculate the minimum and maximum values that appear in the list The steps required to calculate the maximum value from a list are almost identical to those require to calculate the minimum value o To calculate the minimum value of a list of items11-0,-. , N-1} - (Xe,, x-1): Let min Xe. For i = 1,,N-1: . . if Xi min then let min x; o It is meaningless to compute the mean, minimum, or maximum, of an empty set, so we add the following rule If the number of items in the list is 0, then meanminimum maximum0 Test plan o Test your program with several input sequences. Your test plan should include the following categories: An empty sequence (we expect the list to contain 0 items, and the sum to be 0) Exactly 1 value . A "normal" number of elements, i.e. between 1 and 25. Exactly 25 items. More than 25 items (we expect the list to contain 25 items, and only the first 25 items should contribute to the sum The following files contain maximum temperature values for the Brisbane weather station gathered over the period fr 01 January 2018 to 28 February 2019. You can use a couple of these to do some of your tests 201801-max-temp. txt 201802-max-temp. txt 201803-max temp. txt 201803-max-temp. txt 201804-max-temp. txt 201805 max-temp. txt -201806 max-temp. txt -201807-max-temp. txt -201808-max-temp. txt -201809-max-temp. txt 201810-max-temp, txt 201811-max-temp. txt 201812-max-temp. txt 201901-max-temp. txt 201902-max-temp. txt 413-days. txt o Verify the correctness of your results by computing a few terms by hand, or by se alternate but reliable method such as a spreadsheet program o Use input redirection to supply data to the standard input stream of your program. -There are several ways to do this. One easy way is to pipe the output of the echo or cat command into your program. To send a single line containing the values (1 2 34567) to the test driver, use the following comand: echo -n "1 2 3 4 5"| ./array_stats To send the contents of a text file called my-file.txt to the test driver, use the following command: cat my-file.txt | -/array stats See also CAB202 Topic 1 &2 technical notes Practical C Programming o Chapter 4 - Basic declarations and expressions o Chapter 5Arrays, qualifiers, and reading numbers Chapter 6 - Decisions and control statements .CPlusPlus. com Tutorial: Arrays TutorialsPoint: C Arrays Notes: .A program similar to yours produces the output sequences pictured below. The images illustrate a convenient way to invoke the test driver using input redirection to provide the seed values for reading via scanf. Your results will not be exactly the same as this view, because each user gets a unique set of parameters. However, it should give you an idea what to aim for bash $echo -n "1 2 3 45 67 8 9 10" ./array_stats 1.000000 2.000000 3.000000 4.000000 5.000 6.000000 7.000000 8.000000 9.000 10.000000 Item count: 10 Item mean 5.500000 Item min:1.00000e Item max:10.000000 $echo ""|/array_stats Item count: Item mean: 0.000000 Item min -000000 Item max : 0.000000 echo "12"I/array_stats 12.000000 Item count: 1 Item mean 12.000000 Item min12.000000 Item max:12.000000 $echo "14 12 10 8" | "/array-stats 14.000000 12.000000 10.000000 8.000000 Item count: 4 Item mean 11.00e000 Item min 8.0000e Item max:14.000000 $echo "14 12 1.3"./array_stats 14.000000 12.000000 1.300000 Item count: 3 Item mean: 9.100000 Item min1.3000060 Item max14.000000 secho "14 12 1.333333" 1 ./array_stats 14.000000 12.000000 1.333333 Item count: 3 Item mean: Item min1.333333 Item max14.000e00 bash $ cat 413-days.txt | ./array_stats 32.100000 30.800000 31.200000 29 . 50000 29.500000 31.1eeee0 31.5eeeee 32.400000 32.100000 32.366000 31.400000 32.600000 35.666600 37.500000 30.360000 31.10000e 29.400000 30.000000 31.400000 32.200000 30.200000 31.700000 32.300000 31.600000 32.500000 32.800000 30.200000 31.500000 32.70000 34.700000 25.500000 21.780000 22.800000 28.00e0ee 30.10000 Item count: 35 Item mean30.922857 Item min21.700000 Item max37.500000 Use this test driver to implement and test your function prior to submission. #include include include / Declare Global variables here. void array_stats0 f // Insert your solution here include tinc Inde

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

The Database Experts Guide To Database 2

Authors: Bruce L. Larson

1st Edition

0070232679, 978-0070232679

More Books

Students also viewed these Databases questions

Question

The amount of work I am asked to do is reasonable.

Answered: 1 week ago

Question

The company encourages a balance between work and personal life.

Answered: 1 week ago