Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Project 3 Have the user provide a name for the weather station upon entry. Add a

ID: 3889460 • Letter: P

Question

Project 3

Have the user provide a name for the weather station upon entry.

Add a control loop that allows the user to specify which of four actions to take:

- Input a complete weather reading.

- temperature,

- wind speed, and

- wind direction

- Print the current weather

- If the user hasn't entered any data then print a message to that effect (no defaults)

- Exit the program

Use a text-driven menu to present the choices for actions to the user

Warning: this project is going to be graded with heavy testing

C++ code:

// EdwardMagruderweatherstation.cpp : Defines the entry point for the console application.

//Edward Magruder

#include "stdafx.h"

#include <iostream>

#include <string>

using namespace std;

int main()

{

//declaring variables to hold the weather station name, temperature, wind speed, and direction

string weather_station, wind_direction;

double temperature;

int wind_speed;

//assigning some values to the variables

cout << "Enter Name of the weather station:";

getline(cin, weather_station);

cout << "Enter Temperature:";

cin >> temperature;

cout << "Enter wind speed:";

cin >> wind_speed;

cout << "Enter wind direction:";

cin >> wind_direction;

//printing the variables

cout << "The " << weather_station << " Weather Station" << " ";

cout << temperature << " degree F" << " ";

cout << wind_speed << " " << wind_direction << " ";

return 0;

}

Explanation / Answer

#include "stdafx.h"

#include <iostream>

#include <string>

using namespace std;

int main()

{

//declaring variables to hold the weather station name, temperature, wind speed, and direction

string weather_station, wind_direction;

double temperature;

int wind_speed;

   //assigning some values to the variables
   int i=0;
   cout << "Enter Name of the weather station:";
  
   getline(cin, weather_station);
  
   while(i<3)
   {
       switch(i)
       {
           case 0:
               cout << "Enter Temperature:";
               cin >> temperature;
               break;
           case 1:
               cout << "Enter wind speed:";
               cin >> wind_speed;
               break;
           case 2:
               cout << "Enter wind direction:";
               cin >> wind_direction;
               break;          
          
       }
       i++;
   }
  
  
  

   //printing the variables
  
   cout << "The " << weather_station << " Weather Station" << " ";
  
   cout << temperature << " degree F" << " ";
  
   cout << wind_speed << " " << wind_direction << " ";
  
  
  
   return 0;

}