Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

there is a logic error in my program and i would like help on fixing it. #include #include #include #include using namespace std; //function to

there is a logic error in my program and i would like help on fixing it.

image text in transcribedimage text in transcribed

#include #include #include #include using namespace std; //function to read tempratures from file to array

void readTemp(string[], double[]);

void displayTemps(string[], double[], bool);

double findAvgTemp(double[], int);

void convertToFahr(double[], int);

int daysAboveAvg(double[], double);

double findHiTemp(double[], string[], int);

int main() {

double temperatures[92] = { 0 }; double avgF = 0; string Month[3] = { "March","April","May" }; readTemp(Month, temperatures);

displayTemps(Month, temperatures, true);

convertToFahr(temperatures, 92);

displayTemps(Month, temperatures, false); displayTemps(Month, temperatures, false);

avgF = findAvgTemp(temperatures, 92); cout

cout

cout > temp[i++]; } infile.close(); }

void displayTemps(string Month[], double temp[], bool celcius = true) { string months[3] = { "March","April","May" }; string degree = celcius ? "Celcius" : "Fahrenhite"; cout

//function to find average temperature double findAvgTemp(double temp[], int days) { double sum = 0, avg = 0; for (int i = 0; i

//take the celcius and convert it into farenhieght void convertToFahr(double temp[], int days) { for (int i = 0; i

//find the days average int daysAboveAvg(double temp[], double avg) { int count = 0; for (int i = 0; i avg) { count++; } } return count; }

//this funtion is to find the higest tempatur of each month double findHiTemp(double temp[], string Month[], int count) { int days = 0; int totaldays = 0; double monthhi[3];

if (count == 0) { double marchhinum = 0; for (int num = 0; num marchhinum) { monthhi[0] = temp[num]; marchhinum = temp[num]; } } } else if (count == 1) { double aprilnum = 0; for (int x = 32; x

if (temp[x] >aprilnum) { monthhi[1] = temp[x]; aprilnum = temp[x]; } } } else if (count == 2) { double maynum = 0; for (int i = 62; i

if (temp[i] > maynum) { monthhi[2] = temp[i]; maynum = temp[i]; } } } return monthhi[count - 1];

}

this is the lab.txt that is used to find the numbers for the temp

0 -5.55556 -1.66667 6.11111 17.7778 18.8889 23.8889 20.5556 12.2222 24.4444 20.5556 0 7.77778 10.5556 16.6667 16.6667 21.1111 23.3333 12.2222 6.66667 12.7778 16.6667 15.5556 21.1111 15.5556 13.3333 15 15.5556 14.4444 12.7778 18.3333 16.1111 22.7778 13.8889 13.3333 18.3333 8.33333 4.44444 11.6667 16.6667 16.6667 11.6667 12.7778 8.33333 13.8889 7.22222 17.7778 21.6667 23.8889 17.7778 13.3333 10 15.5556 17.7778 28.3333 29.4444 29.4444 28.3333 21.1111 18.8889 22.2222 22.2222 17.7778 20 21.1111 22.2222 18.3333 21.6667 21.1111 19.4444 18.3333 18.3333 20 18.8889 22.2222 26.1111 20.5556 16.1111 18.8889 22.7778 27.2222 28.3333 29.4444 30 30 26.6667 28.8889 27.7778 25 25.5556 25 22.7778

Program 6 25 pts CS2010: Rex Spring, 2018 Due: Wednesday, April 11,2018 Problem: Is the Earth warming up? Are the temperatures we have been experiencing recently normal fluctuations or evidence of a warming trend? Write a C++ program to analyze temperature data from March, April and May of 2017 for Ohio. Create a project using your last name, first initial and pgm for the project folder and cpp file names (e.8. WaveH pgm6 and WaveH pgm6.cpp). Your output may be displayed on the screen. Input: The temperature (in Celsius) for each day of March, April and May (92 temperatures) is stored in the file pgm6.txt. Copy this file from the Canvas class web site (Files 02 Program Assignments) to your project folder. Your project should read in each temperature and store it in the next available element of an array of type double All of the temperatures must be stored in the same array. Use the data values stored in the array to perform the steps described below. Processing: Your main function should do the following: 1. Declare the array to hold the temperatures and any other variables needed. 2. Call a function to read the daily temperatures from the file pgm6.txt, storing each temperature in an element in the array. Open and close the data file inside this function. All further processing must be done using the data values stored in the array. Temperatures in the file look like this: -5.55556 -1.66667 Call a function to display the temperatures for the month of March. Include a heading with your name, class data and two columns-one showing the day of the month and one showing the temperature for that day-see sample below. Note that the temperatures are displayed with no decimal places. 3. Temperatures for March Your Name Cs2010, Spring 2018, xx:xx Temperature Day of month (Celsuis) -6 -2 4 etc. etc. Call a function to convert all of the temperatures in the array from Celsius to Fahrenheit (F-905.0 C + 32), replacing the original Celsius temperature with the Fahrenheit value for each element. Note: You do not need to create a new array for this function, just change the values in the original array. Program 6 25 pts CS2010: Rex Spring, 2018 Due: Wednesday, April 11,2018 Problem: Is the Earth warming up? Are the temperatures we have been experiencing recently normal fluctuations or evidence of a warming trend? Write a C++ program to analyze temperature data from March, April and May of 2017 for Ohio. Create a project using your last name, first initial and pgm for the project folder and cpp file names (e.8. WaveH pgm6 and WaveH pgm6.cpp). Your output may be displayed on the screen. Input: The temperature (in Celsius) for each day of March, April and May (92 temperatures) is stored in the file pgm6.txt. Copy this file from the Canvas class web site (Files 02 Program Assignments) to your project folder. Your project should read in each temperature and store it in the next available element of an array of type double All of the temperatures must be stored in the same array. Use the data values stored in the array to perform the steps described below. Processing: Your main function should do the following: 1. Declare the array to hold the temperatures and any other variables needed. 2. Call a function to read the daily temperatures from the file pgm6.txt, storing each temperature in an element in the array. Open and close the data file inside this function. All further processing must be done using the data values stored in the array. Temperatures in the file look like this: -5.55556 -1.66667 Call a function to display the temperatures for the month of March. Include a heading with your name, class data and two columns-one showing the day of the month and one showing the temperature for that day-see sample below. Note that the temperatures are displayed with no decimal places. 3. Temperatures for March Your Name Cs2010, Spring 2018, xx:xx Temperature Day of month (Celsuis) -6 -2 4 etc. etc. Call a function to convert all of the temperatures in the array from Celsius to Fahrenheit (F-905.0 C + 32), replacing the original Celsius temperature with the Fahrenheit value for each element. Note: You do not need to create a new array for this function, just change the values in the original array

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Concepts Of Database Management

Authors: Philip J. Pratt, Joseph J. Adamski

4th Edition

ISBN: 0619064625, 978-0619064624

More Books

Students also viewed these Databases questions