Question: write a program that reads in climate data (imagine it is coming from a weather station) and stores that data in a linked list. After

write a program that reads in climate data (imagine it is coming from a weather station) and stores that data in a linked list. After reading and storing all of the data your program will generate a report from the data.

The objective of this assignment is to learn how to implement a linked list and to gain familiarity with using a linked list in solving a problem. Since one of the objectives is to learn how to implement a linked list you cannot use the STL linked list.

Your program should use good design methodologies so you should have separate classes for each of the following:

- datalogger -- This class represents the "business logic" of adding data to the storage. This class also handles filtering out duplicate data items (see the requirements listed below). This is the only class that weatherlog.cpp knows about and it expects two methods: addData() and printReport().

- linkedlist -- This class should implement a linked list. This class should be distinct from the datalogger class (although I would expect datalogger to have a data member that is a linkedlist object).

- weatherdata -- This class encapsulates the weather data (time, temperature,windspeed).

You are welcome to create any additional classes that you need. Below are the specific external and internal requirements for this assignment. Your program will be evaluated based on these requirements.

//// External Requirements /////

- The main driver (weatherlog.cpp) will provide a sequence of data readings. The program needs to store these readings. After all of the data is read in, the program must create a report identical to the one in the expected.txt output file.

- Data with a duplicate timestamp indicates contradictory or inaccurate data and should not be stored (all records with the same timestamp).

- The report includes:

- a line that states the timestamp range

- a line that states the number of data entries

- a temperature section that contains a detailed report (see below)

- a windspeed section that contains a detailed report (see below)

- detailed report data:

- the minumum value measured

- the maximum value measured

- a list of all of the readings >= the 99% reading (in order)

- a list of all of the readings <= the 1% reading (in order)

- see the provided "expected.txt" to see the report format

//// Internal Requirements ////

- The program must use the supplied weatherlog.cpp file, unmodified, as the main driver.

- All of the weather data must be stored in a linked list.

- The linked list must have three separate "chains". One that keeps the data ordered by timestamp, one that keeps the data ordered by temperature, and one that keeps the data ordered by windspeed.

- Strings must be stored using char* variables, not std::string.

- No memory leaks.

******** weatherlog.cpp ********

#include

#include

#include "datalogger.h"

using namespace std;

int main(int argc, char** argv) {

datalogger dl;

if (argc != 2) {

cout << "Usage: " << argv[0] << " " << endl;

exit(0);

}

// Read the data

char* datafile = argv[1];

ifstream infile(datafile);

int timestamp;

double temperature;

double windspeed;

while (!infile.eof()) {

infile >> timestamp;

infile >> temperature;

infile >> windspeed;

if (!infile.eof()) {

dl.addData(timestamp, temperature, windspeed);

}

}

// Output the report

dl.printReport();

return(0);

}

******* datalogger.h *******

#ifndef DATALOGGER_H

#define DATALOGGER_H

#include

class weather

{

public:

weather();

weather( int *timestamp, double *temperature, double windspeed);

int *getTimestamp() const;

double *getTemperature() const;

double *getWindspeed() const;

void setTimestamp(int *timestamp);

void setTemperature(double *temperature);

void setWindspeed(double *windspeed);

const weather& operator=(const weather& // ???? to overload assignment operator.

private:

int *timestamp;

double *temperature;

double *windspeed;

};

#endif

/// climatedata.txt ////

// some data to test the program.

1480906168 -226 361

1480906168 -224 270

1480906175 -222 326

1480906179 -218 236

1480906187 -218 145

1480906189 -216 109

1480906189 -212 145

1480906190 -208 153

1480906197 -204 90

1480906197 -201 48

1480906198 -197 38

1480906203 -193 60

1480906209 -190 117

1480906213 -188 108

1480906219 -186 104

1480906225 -185 94

//// Expected.txt ////

-- Data Report --

Time range: 1480906175 - 1480950515

Number of entries: 8075

----------------------------------------------------------------------

TEMPERATURE

Min temperature: -73.1 C

Max temperature: 10.2 C

Top 1% temperatures (>= 9.4):

Timestamp: 1480947842

Temperature: 9.4 C

Windspeed: 10.16 m/s

Timestamp: 1480947802

Temperature: 9.4 C

Windspeed: 11.58 m/s

----------------------------------------------------------------------

WINDSPEED

Min windspeed: 0 m/s

Max windspeed: 26.82 m/s

Top 1% windspeeds (>= 26.56):

Timestamp: 1480937571

Temperature: -18.8 C

Windspeed: 26.56 m/s

Timestamp: 1480918744

Temperature: -64.7 C

Windspeed: 26.56 m/s

Timestamp: 1480937591

Temperature: -17.5

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!