How to search a data base and display information

Hey guys i'm new to programming and have been asked to complete this assignment but I have become confused as to how to finish it. I have the structure basically created and how to call for the file that contains all the data, but I'm confused and don't know what to do in order to determine the site with greatest variation in temperature and highest average wind speed. Can someone please help me.

Here is the project.
You are developing a database of measured meteorological data for use in weather and climate research. Define a structure type measured_data_t (which I have done) with components site_id_num (a four digit integer), wind_speed, day_of_month, and temperature. Each site measures its data daily, at noon local time. Write a program that inputs a file of measured_data_t records and determines the site with the greatest variation in temperature (defined here as teh biggest difference between extrema) and the site with the highest average wind speed for all the days in the file. You may assume that there will be at most ten sites. Test the program on the following July daily data collected over one week at three sites:

ID Day Wind Speed (knots) Temperature (deg C)
2001 10 11 30
2001 11 5 22
2001 12 18 25
2001 13 16 26
2001 14 14 26
2001 15 2 25
2001 16 14 22
3345 10 8 29
3345 11 5 23
3345 12 12 23
3345 13 14 24
3345 14 10 24
3345 15 9 22
3345 16 9 20
3819 10 17 27
3819 11 20 21
3819 12 22 21
3819 13 18 22
3819 14 15 22
3819 15 9 19
3819 16 12 18

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
#include <iostream>
#include <fstream>
#include <iomanip>
#include <string>
#include <algorithm>
using namespace std;

const int MAX_ID = 3345;			// Maximum siteIDNumber
const int MAX_WINDSPEED = 22;		// Maximum windSpeed
const int MAX_DAY = 16;				// Maximum dayOfMonth
const int MAX_TEMP = 30;			// Maximum temperature

struct MeasuredData
{
	string siteIDNumber, dayOfMonth;
	int windSpeed,
		temperature;
};

struct SearchParams
{
	string lowID, highID,
		   lowDay, highDay;
	int lowwindSpeed, highwindSpeed,
		lowtemp, hightemp;
};

void getParams( SearchParams& params );
void displayMatch( ifstream& database, const SearchParams& params );

void int main ()
{
	string dataFile;	// File containing measured data values
	SearchParams params;

	cout << " Enter file name containg data values " << endl;
	cin >> dataFile;
	ifstream measuredData (dataFile.c_str(), ios::in);

	if (!measuredData.fail())
	{
		getParams(params);
		displayMatch( measuredData, params );
		measuredData.close();
	}

	else
	{
		cout << " Cannot open file " << dataFile << endl;
	}

	system("pause");
	return 0;
}
Last edited on
Topic archived. No new replies allowed.