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
- Name your file as
ex2.cpp
- Add
#include "ex2HeadFile.h"
in yourex2.cpp
- File
ex2HeadFile.h
includes one linevoid ex2();
- Name your main function as
void ex2()
- Don't add
main()
function in yourex2.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
- Status
- Finished
- Problems
- 5
- Open Since
- 2020-08-01 00:00
- DDL
- 2020-08-07 23:59
- Extension
- 24.0 hour(s)