Homework7 Problem 2

Homework7 Problem 2

You cannot submit for this problem because the homework's deadline is due.

Description

Read in values from a given file ”text.txt”, and print the mean of the values, max-
imum value, minimum value, and the range of the read-in values onto the screen.
Sample input in ”text.txt”

Format

  1. Name your file as ex2.cpp
  2. Add #include "ex2HeadFile.h" in your ex2.cpp
  3. File ex2HeadFile.h includes one line void ex2();
  4. Name your main function as void ex2()
  5. Don't add main() function in your ex2.cpp

Special Requirement for JOJ

the mean value should be stored with int type, and the decimal should be discarded. For example, when mean is calculated to be 4.6, you should output 4.

Sample Version

// You can add other library, e.g. `iostream`. 
#include "ex2HeadFile.h"
void ex2()
{
    #TODO: Add your implementation here. 
}

Input

From the file text.txt input multiple numbers.

Output

Output to the standard output. Following the format in the sample IO. For mean, just output the integer part.

Sample 1

Input (In file text.txt)

2
1
3

Output

Mean: 2
Max: 3
Min: 1
Range: 2

Specification

All numbers in the given file are int type and promise there're at least one number.

Homework 7

Not Claimed
Status
Finished
Problems
5
Open Since
2020-08-01 00:00
DDL
2020-08-07 23:59
Extension
24.0 hour(s)