 # Temperature Program Using C++

## Question

A file gives all of the temperatures for a period of time. Each number in the file is the temperature for 1 day. The number of days could be a month, a year, or the duration of a trip. You are to read in all of the temperatures from the file and print the following statistics:

The number of days
The temperature range, example: The temperatures ranged from -5 to 45
The average temperature
The number of days (if any) that were freezing (32 degrees or less). Don't print if 0!
The number of days (if any) that were 100 degrees or more. Don't print if 0!
Example 1:
The file contains these numbers:
20
15
32
40
37
Output:
There were 5 days.
The temperatures ranged from 15 to 40.
The average temperature was 28.8
It was freezing on 3 days.
Example 2:
The file contains these numbers:
85
90
95
100
102
70
80
90
Output:
There were 8 days.
The temperatures ranged from 70 to 102.
The average temperature was 89.
It was 100 degrees or more on 2 days.

## Solution Preview

This material may consist of step-by-step explanations on how to solve a problem or examples of proper writing, including the use of citations, references, bibliographies, and formatting. This material is made available for the sole purpose of studying and learning - misuse is strictly forbidden.

#include <iostream>
#include <fstream>

using namespace std;

int main()
{
ifstream inFile;
char data;
int count = 0, min, max, total = 0, freezing = 0, hot = 0;
double average;
inFile.open("input.txt", ifstream::in);

while(!inFile.eof())
{
inFile.getline(data, 5);
int num = atoi(data);
if(count == 0 || max < num)
max = num;
if(count == 0 || min > num)
min = num;
if(num <= 32)...
\$20.00 for this solution

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

### Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.