The client should read in the file contents and store them in the object. The file will be formatted such that the first line contains the month name, the second line contains the year, and each successive line contains a temperature. A typical input file might contain:     June 2019 90 85 97 91 87 86 88 82 83 85

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

Can i get help writing this program in c++ on microsoft visual 19

with this input file incorporated.

The client should read in the file contents and store them in the object. The file will be formatted such that the first line contains the month name, the second line contains the year, and each successive line contains a temperature. A typical input file might contain:

 

 

June

2019

90

85

97

91

87

86

88

82

83

85

This assignment utilizes a class in an application that might be useful in the "real world." It
requires the sorting of, and computation with, data involving temperatures.
Requirements:
You are working for a meteorologist to maintain a list of temperatures and some related statistics
for a month.
Class and Data members:
Create a class called Temperature that stores temperature readings (integers) in a vector (do not
use an array). The class should have data members that store the month name and year of when
the temperature readings were collected.
Constructor(s):
The class should have a 2-argument constructor that receives the month name and year as
parameters and sets the appropriate data members to these values.
Member Functions:
The class should have functions as follows:
1. Member functions to set and get the month and year variables.
2. A member function that adds a single temperature to the vector. Both negative and positive
temperatures are allowed. Call this function AddTemperature.
3. A member function to sort the vector in ascending order.
Feel free to use the sort function that is available in the algorithm library for sorting vectors.
Or, if you would prefer to write your own sort code, you may find this site to be helpful:
http://www.cplusplus.com/articles/NHAORXSZ/
4. A member function to compute the average (x) of the temperatures in the vector. The formula for
calculating an average is
x= Exi/n
where xi is the value of each temperature reading and
n is the total number of temperature readings in the vector.
5. A member function to determine the lowest temperature for the month. [Note that to receive
credit for this function, it must contain an algorithm to search through the vector to determine the
minimum value. You cannot simply sort the vector and return the first data member.]
Transcribed Image Text:This assignment utilizes a class in an application that might be useful in the "real world." It requires the sorting of, and computation with, data involving temperatures. Requirements: You are working for a meteorologist to maintain a list of temperatures and some related statistics for a month. Class and Data members: Create a class called Temperature that stores temperature readings (integers) in a vector (do not use an array). The class should have data members that store the month name and year of when the temperature readings were collected. Constructor(s): The class should have a 2-argument constructor that receives the month name and year as parameters and sets the appropriate data members to these values. Member Functions: The class should have functions as follows: 1. Member functions to set and get the month and year variables. 2. A member function that adds a single temperature to the vector. Both negative and positive temperatures are allowed. Call this function AddTemperature. 3. A member function to sort the vector in ascending order. Feel free to use the sort function that is available in the algorithm library for sorting vectors. Or, if you would prefer to write your own sort code, you may find this site to be helpful: http://www.cplusplus.com/articles/NHAORXSZ/ 4. A member function to compute the average (x) of the temperatures in the vector. The formula for calculating an average is x= Exi/n where xi is the value of each temperature reading and n is the total number of temperature readings in the vector. 5. A member function to determine the lowest temperature for the month. [Note that to receive credit for this function, it must contain an algorithm to search through the vector to determine the minimum value. You cannot simply sort the vector and return the first data member.]
CSIS 112
6. A member function to determine the highest temperature for the month. [Note that to receive
credit for this function, it must contain an algorithm to search through the vector to determine the
maximum value. You cannot simply sort the vector and retum the last data member.]
7. Amember function to retum the number of temperatures that were read in for the month.
8. A member function to display the sorted temperatures.
Write a program (client) that uses the class by creating a Temperatures object and prompting the
user for a file name. Appropriate error checking is required to ensure that the file exists and can
be opened successfully.
Note that the file may contain any number of temperatures for a given month. Therefore, you
need to read in and store each temperature until you reach the end of the file.
The client (i.e. main(0) should read in the contents of the file. After each temperature is read in,
it should call the member function in the Temperatures class to add the new temperature (i.e.
one temperature at a time) to the vector.
Main() should then produce a report that displays the month and year of the data, the total
number of observations (temperatures) in the file, the lowest temperature, the highest
temperature, the average temperature, and finally, a listing of all of the temperatures that were
read in. The listing of all of the temperatures must be displayed in sorted order (ascending -
from lowest to highest).
All output should be labeled appropriately, and validity checking should be done on input of the
filename and also the temperatures that are read in.
If a non-numeric value is encountered in reading in the temperatures, the program should output
an error message indicating that a non-numeric value was found in the file, and the entire
program should then terminate. If a non-numeric is found, consider the entire file to be
corrupted and don't try to produce any calculations nor display the contents of the vector - just
end the program with an appropriate error message. (Make sure the error message is displayed
long enough for the user to read it before ending the program.) Again, negative temperatures are
permitted, but non-numeric temperatures should be caught.
The executing program should look something like this:
Transcribed Image Text:CSIS 112 6. A member function to determine the highest temperature for the month. [Note that to receive credit for this function, it must contain an algorithm to search through the vector to determine the maximum value. You cannot simply sort the vector and retum the last data member.] 7. Amember function to retum the number of temperatures that were read in for the month. 8. A member function to display the sorted temperatures. Write a program (client) that uses the class by creating a Temperatures object and prompting the user for a file name. Appropriate error checking is required to ensure that the file exists and can be opened successfully. Note that the file may contain any number of temperatures for a given month. Therefore, you need to read in and store each temperature until you reach the end of the file. The client (i.e. main(0) should read in the contents of the file. After each temperature is read in, it should call the member function in the Temperatures class to add the new temperature (i.e. one temperature at a time) to the vector. Main() should then produce a report that displays the month and year of the data, the total number of observations (temperatures) in the file, the lowest temperature, the highest temperature, the average temperature, and finally, a listing of all of the temperatures that were read in. The listing of all of the temperatures must be displayed in sorted order (ascending - from lowest to highest). All output should be labeled appropriately, and validity checking should be done on input of the filename and also the temperatures that are read in. If a non-numeric value is encountered in reading in the temperatures, the program should output an error message indicating that a non-numeric value was found in the file, and the entire program should then terminate. If a non-numeric is found, consider the entire file to be corrupted and don't try to produce any calculations nor display the contents of the vector - just end the program with an appropriate error message. (Make sure the error message is displayed long enough for the user to read it before ending the program.) Again, negative temperatures are permitted, but non-numeric temperatures should be caught. The executing program should look something like this:
Expert Solution
Step 1

Required C++ code along with screenshot of code and output given below :

trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 4 steps with 4 images

Blurred answer
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