Project 7 .CPP: Edwardmagruderweatherstation
Project 7 .CPP: Edwardmagruderweatherstation
programming project and then break up each part of the code and write what that part of
the code does. For example,
The entire program code
- Detailed summary and description of what the program does
Snippet of code in the program
- detailed summary and description of what it does
Keep doing that for the code
Thank you. I appreciate it
C++ code:
Project 7
EdwardMagruderWeatherStation.cpp
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include<string>
#include <stdlib.h>
#include<vector>
#include<sstream>
#include "weather.h"
using namespace std;
string DisplayMenu(string station_name)
{
string str, temp;
do
{
cout << "*******************WEATHER STATION: " << station_name\
<< " *******************" << endl << endl;
cout << "I. Input a complete weather reading." << endl;
cout << "P. Print the current weather." << "\n";
cout << "H. Print the weather history (from most recent to oldest)." << endl;
cout << "E. Exit the program." << "\n";
cout << "Enter your choice: " << endl;
cin >> str;
temp = str;
for (std::string::size_type i = 0; i < str.length(); ++i)
temp[i] = toupper(str[i]);
str = temp;
} while (!(str == "I" || str == "P" || str == "H" || str == "E"));
return str;
}
/*
double getTemperature()
{
double temp;
string temp_string;
stringstream converter;
cout << "Enter the temperature: ";
cin >> temp_string;
converter << temp_string;
converter >> temp;
return temp;
}
double getWindSpeed()
{
double temp;
string temp_string;
stringstream converter;
//this loop will be iterated continuously untill user enters windspeed which is greater than
zero
do
{
cout << "Enter Wind speed(>=0): ";
cin >> temp_string;
converter << temp_string;
converter >> temp;
if (temp <= 0)
cout << "Wind speed should be always greater or equal to 0(zero)";
} while (temp < 0);
return temp;
}
string getWindDirection()
{
string temp_string, temp;
do {
cout << "Enter the Wind Direction (North,South,East,West): ";
cin >> temp_string;
temp = temp_string;
for (std::string::size_type i = 0; i < temp_string.length(); ++i)
temp[i] = toupper(temp_string[i]);
} while (!(temp == "NORTH" || temp == "SOUTH" || temp == "EAST" || temp ==
"WEST"));
temp_string = temp;
return temp_string;
};
void printWeather(Weather_Station ws)
{
cout << "Station Name " << ws.name << endl;
cout << "Temperature " << ws.temperatureMeasure.temperature << endl;
cout << "Wind Direction " << ws.windMeasure.windDirection << endl;
cout << "Wind Speed " << ws.windMeasure.windspeed << endl;
cout << endl;
}
*/
int main()
{
//Have the user provide a name for the weather station upon entry.
weather_t * history;
int historySize;
if (myWeather_Details.windMeasure.windspeed >= 0)
{
valid_wind_speed = 1;
}
if ((myWeather_Details.windMeasure.windDirection == "NORTH") ||
(myWeather_Details.windMeasure.windDirection == "SOUTH") ||
(myWeather_Details.windMeasure.windDirection == "EAST") ||
(myWeather_Details.windMeasure.windDirection == "WEST"))
{
valid_wind_direction = 1;
}
//store the details
if (valid_wind_direction && valid_wind_speed)
myStation.push_back(myWeather_Details);
*/
for (int i = historySize - 1; i > 0; i--) {
history[i] = history[i - 1];
}
history[0] = getWeather();
histCount++;
}
else if (input_choice == "P")
{
{
exit(0);
}
}
return 0;
}
temperature.cpp
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include<string>
#include <stdlib.h>
#include<vector>
#include<sstream>
#include "temperature.h"
using namespace std;
temperature_t getTemperature()
{
temperature_t temp;
string temp_string;
stringstream converter;
cout << "Enter the temperature: ";
cin >> temp_string;
converter << temp_string;
converter >> temp.temperature;
return temp;
}
weather.cpp
#include "stdafx.h"
#include "temperature.h"
#include<string>
#include<sstream>
#include "weather.h"
void printWeather(weather_t ws)
{
//cout << "Station Name " << ws.name << "\n";
cout << "Temperature " << ws.temperature.temperature << "\n";
cout << "Wind Direction " << ws.wind.direction << "\n";
cout << "Wind Speed " << ws.wind.speed << "\n";
cout << "\n";
}
weather_t getWeather() {
weather_t result;
result.wind = getWind();
result.temperature = getTemperature();
return result;
}
wind.cpp
#include "stdafx.h"
#include "wind.h"
#include <stdio.h>
#include <iostream>
#include<string>
#include <stdlib.h>
#include<vector>
#include<sstream>
using namespace std;
double getWindSpeed()
{
double temp = -1;
string temp_string;
stringstream converter;
//this loop will be iterated continuously untill user enters windspeed which is greater than
zero
do
{
cout << "Enter Wind speed(>=0): ";
cin >> temp_string;
stringstream(temp_string) >> temp;
if (temp < 0)
cout << "Wind speed should be always greater or equal to 0(zero)";
} while (temp < 0);
return temp;
}
string getWindDirection()
{
string temp_string, temp;
do {
cout << "Enter the Wind Direction (North,South,East,West): ";
cin >> temp_string;
temp = temp_string;
for (std::string::size_type i = 0; i < temp_string.length(); ++i)
temp[i] = toupper(temp_string[i]);
} while (!(temp == "NORTH" || temp == "SOUTH" || temp == "EAST" || temp
=="WEST"));
temp_string = temp;
return temp_string;
};
wind_t getWind() {
wind_t result;
result.speed = getWindSpeed();
result.direction = getWindDirection();
return result;
}
temperature.h
#pragma once
struct temperature_t {
int temperature;
};
temperature_t getTemperature();
weather.h
#pragma once
#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include<string>
#include <stdlib.h>
#include<vector>
#include<sstream>
#include "wind.h"
#include "temperature.h"
using namespace std;
struct weather_t {
wind_t wind;
temperature_t temperature;
};
weather_t getWeather();
void printWeather(weather_t ws);
wind.h
#include<string>
#pragma once
struct wind_t {
double speed;
std::string direction;
};
wind_t getWind();
EXIT
i need 5 9 and 10 answered (need the syntax to be copy and paste ) and screenshots of the
output thank you ..
using functions
Write a C++ program that reads a list of double-precision grades from the keyboard into
an array named grade. The grades are to be counted as they’re read. After all grades have
been input, your program should find and display the sum, median, mean and standard
deviation of the grades. The grades should then be listed with an asterisk (*) placed in
front of each grade that’s below the average.
The program should also display each grade and its letter equivalent, using the following
scale:
Between 70 and 100 = A.
Greater than or equal to 60 and less than 70 = B.
Greater than or equal to 50 and less than 60 = C.
Greater than or equal to 40 and less than 50 = D.
Less than 40 = F.
else if(grade>=40&&grade<50)
return ‘c’;
else if(grade<40)
return ‘c’;
else if(grade==7)
return 'C';
else if(grade==6)
return 'D';
else if(grade>=0 && grade<=5)
return 'F';
else
return 'E';
}
double CalculateMean()
{
double sum = 0;
for(int i = 0; i < max; i++)
sum += value[i];
return (sum / max);
}
double CalculateVariane()
{
mean = CalculateMean();
double temp = 0;
for(int i = 0; i < max; i++)
{
temp += (value[i] - mean) * (value[i] - mean) ;
}
return temp / max;
}
double GetStandardDeviation()
{
return sqrt(CalculateVariane());
}