Question

Therefore, for this program you will read the data in the file named weatherdata_2.txt into arrays...

Therefore, for this program you will read the data in the file named weatherdata_2.txt into arrays for the wind speed and for the temperature. You will then use the stored data to calculate and output the average wind speed and the average temperature.

Create a constant with a value of 30 and use that to declare and loop through your arrays and as a divisor to produce your averages.

Here is the data file (below).

1. 14 25

2. 12 31

3. 5 35

4. 11 33

5. 8 21

6. 9 35

7. 12 25

8. 13 34

9. 8 32

10. 13 28

11. 6 32

12. 13 29

13. 6 28

14. 8 35

15. 5 25

16. 6 28

17. 8 34

18. 8 21

19. 3 31

20. 15 22

21. 5 35

22. 6 33

23. 12 27

24. 15 27

25. 12 34

26. 14 23

27. 14 22

28. 5 21

29. 7 29

30. 14 22

Thank you in advance!

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:

#include<iostream>
#include<fstream>
#include <iostream>
#include<string>
using namespace std;

int main()
{
int n = 30;
int a = 0;
int num;
int totalWindSpeed = 0, totalTemp = 0, avgWindSpeed, avgTemp;
int temp[100], wind[100];
  
//opening file
ifstream File("weatherdata_2.txt");
while(!File.eof()) //reading file until the last
{
File >> temp[a];
File >> wind[a];
a++;
}
//closing file
File.close();
  
//calculating total
   for(int i=0;i<n;i++)
{
totalTemp += temp[i];
totalWindSpeed += wind[i];
}
//printing average
cout << "Average Wind Speed = " << totalWindSpeed/n << endl << "Average Temparature = " << totalTemp/n << endl;
return 0;
}

OUTPUT:

Add a comment
Know the answer?
Add Answer to:
Therefore, for this program you will read the data in the file named weatherdata_2.txt into arrays...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using the data in the file named “Dataset 1,” to determine is there was a change...

    Using the data in the file named “Dataset 1,” to determine is there was a change in the number of tons of paper used after the implementation of a recycling program in 25 different districts. a. Is this study using dependent or independent samples? b. What is your research hypothesis? c. Using Excel, calculate your test statistic and p-value. Paste the output here. d. What do you conclude? Below is the data set that is mentioned above Before Recycling 20...

  • In a psychiatric study of families of schizophrenic children two Rorshach scores of the mothers (M, and M,)

    III. In a psychiatric study of families of schizophrenic children two Rorshach scores of the mothers (M, and M,) and fathers ( F, F,) were of particular import. The observed values of these scores for parents of nl=10 psychotic adolescents and n2=10 normal control children of similar age and economic status are given below:SchizophreniacontrolM1M2F1F2M1M2F1F230352533201526252141152111318192732253472118353431362115242220371421151117132338192513122015282726302213221932422937539122636273321132019293524321412108 Analyze this data.

  • These are my instructions: Your data should have been read in from the data file and stored into ...

    These are my instructions: Your data should have been read in from the data file and stored into an array. Next you need to calculate the following and display in a single Message box: Average score Highest score Lowest score Mode of the scores Your program should be written using methods and should be well documented internally and externally. Your output should be displayed using Message boxes. This is the .text file to use with the instructions: 20 21 22...

  • Magic Square question for Python

    You have this solution in Java, I am interested in this same solution for Python.One interesting application of two-dimensional arrays is magic squares. A magic square is a square matrix in which the sum of every row, every column, and bothdiagonals is the same. Magic squares have been studied for many years, and there are some particularly famous magic squares. In this exercise you will write code todetermine whether a square is magic.You should find that the first, second, and...

  • Once you have the dataset, please use knowledge gained in other business and/or economics classes to...

    Once you have the dataset, please use knowledge gained in other business and/or economics classes to realize what topic and theory the data could relate and a research question that it could allow you to answer. More specifically, please put together an analysis by making sure your project report includes the following 1. Make a decision about the null and research hypothesis by comparing the obtained value to the critical value and interpret the results of the data. You can...

  • Arrays: City temperatures The maximum daily temperatures (in "C) for Istanbul and Ankara during August 2019...

    Arrays: City temperatures The maximum daily temperatures (in "C) for Istanbul and Ankara during August 2019 are given below. Ankara: [33 30 31 32 33 35 30 29 29 28 29 30 32 32 33 32 34 31 33 30 29 30 31 33 31 30 27 26 27 26 27] Istanbul: [35 32 32 31 34 30 29 32 34 35 36 35 34 32 33 33 34 35 35 34 32 30 30 29 28 31 32 30...

  • A soft drink manufacturer uses fire agents to handle premium distribution for is various products. The marketing director desired to study the timeliness with which the premiums are distributed. Twent...

    A soft drink manufacturer uses fire agents to handle premium distribution for is various products. The marketing director desired to study the timeliness with which the premiums are distributed. Twenty transactions for each agent were selected at random and the time lapse (in days) for handling each transaction was determined. The results follow: Agent 1 Agent 2 Agent 3 Agent 4 Agent 5 24 18 10 15 33 24 20 11 13 22 29 20 8 18 28 20 24...

  • A doctor discovers a particular disease and determines the life expectancy is not good. He gathers...

    A doctor discovers a particular disease and determines the life expectancy is not good. He gathers the data for his patents and posts it in the table below. The claims that the average life expectancy once the disease presents itself is less than 15 days. Check his claim and make an appropriate report about your findings Patient Days till passing Days -Patient # 1-24 2 -23 3 -13 4 -20 5 -10 6 -18 7 -13 8 -14 9 -24...

  • Write a Java program that will read in this XLS file and store them in an...

    Write a Java program that will read in this XLS file and store them in an ArrayList or LinkedList or HashMap Ask user to input what country they wish to search for and then output the country population. Also ask user which other countries they wish to compare. then compare the two countries by outputting both country population NOTE: THIS IS AN XLS FILE F9 Population 1 Country 2 31056997 3581655 32930091 57794 71201 12127071 13477 69108 39921833 2976372 71891...

  • Pls help on filling out Tritraion of a Polyprotic acid chart Data from lab Titration #1...

    Pls help on filling out Tritraion of a Polyprotic acid chart Data from lab Titration #1 Titration #2 Titration #3 mL base added pH mL base added pH mL base added pH 1 0.7 1 0.7 1 0.7 2 1.1 2 1 2 0.9 3 1.5 3 1.4 3 1.3 4 1.7 4 1.6 4 1.5 5 1.9 5 1.8 5 1.7 6 2 6 2.1 6 2 7 2.2 7 2.2 7 2.2 8 2.4 8 2.3 8 2.2...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT