[SOLVED] CSC230 Exercise 24- First C++ : I/O and a simple class

25.00 $

Category:
Click Category Button to View Your Next Assignment | Homework

You will receive the following solution file(s) instantly after successful payment:

zip file icon Exercise24-nn8p9b.zip (13.2 KB)
Assignment Instructions Updated Recently? Submit Below and we will provide new Solution!
Submit New Instructions
πŸ”’ Securely Powered by:
Secure Checkout
Rate this product

First C++ : I/O and a simple class

You’ll find a source file, total.cpp and an input file, numbers.txt on the course homepage.

The main function in this program is empty. Add code to main to open the numbers.txt input file. Read in all the numbers, add them up and print out a total as illustrated below. Use a C++ ifstream to read the input, and use cout to print out the total, the average, the max and the min at the end.

The totals, count of values read, max, and min so far are data members of a class Stats. Your program will initialize these values in the constructor for this class, will call a member function fupdate(number) for each number read in, and member functions ftotal(), fcount(), faverage() (returns a float), fmin(), and fmax() to access the values of the private data members. The programs outputs a message when all numbers are read.

When you’re done, you should be able to run your program as follows. Copy the file you want to test with to numbers.txt, then

$ ./total
Total: 511, count: 9, average: 56.7778, min: 8, max: 106

Or, if numbers.txt is empty,
$ ./total
No numbers in input file

Submit a copy of your completed total.cpp file using the exercise_24 assignment on Moodle.

  • exercise24-oaysy7.zip