
// 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

Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images

- 11:02 all 10% + Create 1 1000.01 Create 2 2000.02 Create 3 3000.03 Deposit 111.11 Deposit 2 22.22 Withdraw 4 5000.00 Create 4 4000.04 Withdraw 1 0.10 Balance 2 Withdraw 2 0.20 Deposit 3 33.33 Withdraw 4 0.40 Bad Command 65 Balance 1 Balance 2 Balance 3 Balance 4arrow_forwardC++ Coding: ArraysTrue and False Code function definitions for eoNum() and output(): Both eoNum() and output() are recursive functions. output() stores the even/odd value in an array. Store 0 if the element in the data array is even and store 1 if the element in the data array is odd. eoNum() displays all the values in an array to the console.arrow_forwardCONSTRUCTOR// IntSet()// Pre: (none)// Post: The invoking IntSet is initialized to an empty// IntSet (i.e., one containing no relevant elements).// CONSTANT MEMBER FUNCTIONS (ACCESSORS)// int size() const// Pre: (none)// Post: Number of elements in the invoking IntSet is returned.// bool isEmpty() const// Pre: (none)// Post: True is returned if the invoking IntSet has no relevant// relevant elements, otherwise false is returned.// bool contains(int anInt) const// Pre: (none)// Post: true is returned if the invoking IntSet has anInt as an// element, otherwise false is returned.// bool isSubsetOf(const IntSet& otherIntSet) const// Pre: (none)// Post: True is returned if all elements of the invoking IntSet// are also elements of otherIntSet, otherwise false is// returned.// By definition, true is returned if the invoking IntSet// is empty (i.e., an empty IntSet…arrow_forward
- C++HurdleGame The HurdleGame class contains all the functions invoked as a result of a user action (i.e. when a user presses a key on the Hurdle Frontend, one of the functions in HurdleGame will be called. A HurdleGame object comprises a HurdleWords object (which stores all valid guesses and valid Hurdles), and a HurdleState object, which stores and tracks all the game states. Any action should update the HurdleState object.Each function in HurdleGame is called as a result of a user action on the Hurdle Frontend. To understand this, please read the Hurdle Backend API section below before implementing. You are responsible for implementing each of the functions below. LetterEntered ● Called by the Hurdle frontend when the user enters a letter. ● Hint: when a user enters a letter, how should the underlying HurdleState be modified to reflect the change resulting from that key press? WordSubmitted ● Called by the Hurdle front end when the user submits a guess by pressing enter. ● Hint: when…arrow_forward# dates and times with lubridateinstall.packages("nycflights13") library(tidyverse)library(lubridate)library(nycflights13) Qustion: Create a function called date_quarter that accepts any vector of dates as its input and then returns the corresponding quarter for each date Examples: “2019-01-01” should return “Q1” “2011-05-23” should return “Q2” “1978-09-30” should return “Q3” Etc. Use the flight's data set from the nycflights13 package to test your function by creating a new column called quarter using mutate()arrow_forwardPLEASE CODE IN PYTHON PLEASE USE NESTED CLASS FUNCTION Design a Point Class with attributes X and Y coordinates. The Class should have following functions: a) change the coordinates, b) return a 2 element list [x,y] c) print a Point object. d) return distance from this instance to a given [x,y] Also design a Line Class which has 2 Point attributes. The Line class should have functions for following behaviours: a) Return the length of the line. b) Print the equation of the line c) Find if this instance is equal in length to another line.arrow_forward
- TRUE OR FALSE, C++ When passing an array to a function, you must include & in front of the array name. When passing an array to a function, you must include & in front of the array name. It is possible to have a 2-dimensional array where each row has a different number of columns. The * is called the address of operator.arrow_forwardGame of Hunt in C++ language Create the 'Game of Hunt'. The computer ‘hides’ the treasure at a random location in a 10x10 matrix. The user guesses the location by entering a row and column values. The game ends when the user locates the treasure or the treasure value is less than or equal to zero. Guesses in the wrong location will provide clues such as a compass direction or number of squares horizontally or vertically to the treasure. Using the random number generator, display one of the following in the board where the player made their guess: U# Treasure is up ‘#’ on the vertical axis (where # represents an integer number). D# Treasure is down ‘#’ on the vertical axis (where # represents an integer number) || Treasure is in this row, not up or down from the guess location. -> Treasure is to the right. <- Treasure is to the left. -- Treasure is in the same column, not left or right. +$ Adds $50 to treasure and no $50 turn loss. -$ Subtracts…arrow_forward
- Computer Networking: A Top-Down Approach (7th Edi...Computer EngineeringISBN:9780133594140Author:James Kurose, Keith RossPublisher:PEARSONComputer Organization and Design MIPS Edition, Fi...Computer EngineeringISBN:9780124077263Author:David A. Patterson, John L. HennessyPublisher:Elsevier ScienceNetwork+ Guide to Networks (MindTap Course List)Computer EngineeringISBN:9781337569330Author:Jill West, Tamara Dean, Jean AndrewsPublisher:Cengage Learning
- Concepts of Database ManagementComputer EngineeringISBN:9781337093422Author:Joy L. Starks, Philip J. Pratt, Mary Z. LastPublisher:Cengage LearningPrelude to ProgrammingComputer EngineeringISBN:9780133750423Author:VENIT, StewartPublisher:Pearson EducationSc Business Data Communications and Networking, T...Computer EngineeringISBN:9781119368830Author:FITZGERALDPublisher:WILEY





