// This program reads floating point data from a data file and places those // values into the private data member called values (a floating point array) // of the FloatList class. Those values are then printed to the screen. // The input is done by a member function called GetList. The output // is done by a member function called PrintList. The amount of data read in // is stored in the private data member called length. The member function // GetList is called first so that length can be initialized to zero. #include #include #include using namespace std; const int MAX_LENGTH = 50; // MAX_LENGTH contains the maximum length of our list class FloatList // Declares a class that contains an array of // floating point numbers { public: void getList(ifstream&); // Member function that gets data from a file void printList() const;// Member function that prints data from that // file to the screen. FloatList();// constructor that sets length to 0. ~FloatList();// destructor private: int length;// Holds the number of elements in the array float values[MAX_LENGTH]; // The array of values };   int main() { ifstream tempData; // Defines a data file // Fill in the code to define an object called list of the class FloatList cout << fixed << showpoint; cout << setprecision(2); tempData.open("temperatures.txt"); // Fill in the code that calls the getList function. // Fill in the code that calls the printList function. return 0; } FloatList::FloatList() { // Fill in the code to complete this constructor that // sets the private data member length to 0 } // Fill in the entire code for the getList function // The getList function reads the data values from a data file // into the values array of the class FloatList // Fill in the entire code for the printList function // The printList function prints to the screen the data in // the values array of the class FloatList // Fill in the code for the implementation of the destructor     This program has an array of floating point numbers as a private data member of a class. The data file contains floating point temperatures which are read by a member function of the class and stored in the array. Why does the member function printList have a const after its name but getList does not? Fill in the code so that the program reads in the data values from the temperature file and prints them to the screen with the following output: 78.90 87.40 60.80 70.40 75.60 Add code (member function, call and function implementation) to print the average of the numbers to the screen so that the output will look like the output from Exercise 2 plus the following: The average temperature is 74.62

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question


// This program reads floating point data from a data file and places those // values into the private data member called values (a floating point array) // of the FloatList class. Those values are then printed to the screen.
// The input is done by a member function called GetList. The output
// is done by a member function called PrintList. The amount of data read in // is stored in the private data member called length. The member function
// GetList is called first so that length can be initialized to zero.
#include <iostream>
#include <fstream>
#include <iomanip>

using namespace std;
const int MAX_LENGTH = 50; // MAX_LENGTH contains the maximum length of our list
class FloatList // Declares a class that contains an array of
// floating point numbers
{ public:
void getList(ifstream&); // Member function that gets data from a file
void printList() const;// Member function that prints data from that
// file to the screen.
FloatList();// constructor that sets length to 0.
~FloatList();// destructor

private:
int length;// Holds the number of elements in the array
float values[MAX_LENGTH]; // The array of values
};

 

int main() {
ifstream tempData; // Defines a data file

// Fill in the code to define an object called list of the class FloatList

cout << fixed << showpoint;
cout << setprecision(2);
tempData.open("temperatures.txt");
// Fill in the code that calls the getList function.
// Fill in the code that calls the printList function.
return 0; }
FloatList::FloatList() {
// Fill in the code to complete this constructor that
// sets the private data member length to 0
}
// Fill in the entire code for the getList function
// The getList function reads the data values from a data file
// into the values array of the class FloatList
// Fill in the entire code for the printList function
// The printList function prints to the screen the data in
// the values array of the class FloatList
// Fill in the code for the implementation of the destructor

 

 

This program has an array of floating point numbers as a private data member of a class. The data file contains floating point temperatures which are read by a member function of the class and stored in the array.
Why does the member function printList have a const after its name but getList does not?

Fill in the code so that the program reads in the data values from the temperature file and prints them to the screen with the following output:
78.90
87.40
60.80
70.40
75.60
Add code (member function, call and function implementation) to print the average of the numbers to the screen so that the output will look like the output from Exercise 2 plus the following:

The average temperature is 74.62

Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 3 steps with 1 images

Blurred answer
Similar questions
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY