Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Project 5 Extend the functionality of project 4 to - incorporate a history of the past 4 weather measurements - update the user menu to

Project 5

Extend the functionality of project 4 to

- incorporate a history of the past 4 weather measurements

- update the user menu to include

- printing the current weather

- printing the weather history (from most recent to oldest)

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

c++ code:

#include using namespace std;

void moveTemperaturesToRight(double temperatures[], double windSpeed[], string windDirection[]) { for(int i = 3; i > 0; i--) { temperatures[i] = temperatures[i-1]; windSpeed[i] = windSpeed[i-1]; windDirection[i] = windDirection[i-1]; } } int main() { string name; int choice; int numOfReadings = 0; double temperatures[4], windSpeeds[4]; string windDirections[4]; //Have the user provide a name for the weather station upon entry. cout << "Enter the name of weather station: "; cin >> name; //Control loop to perform various actions. while(true) { cout << "1. Input a complete weather reading." << endl; cout << "2. Print the current weather." << endl; cout << "3. Print the weather history (from most recent to oldest)." << endl; cout << "4. Exit the program." << endl; cout << "Enter your choice: "; cin >> choice; //Switch based on choice. switch(choice) { case 1: moveTemperaturesToRight(temperatures, windSpeeds, windDirections); cout << "Enter the temperature: "; cin >> temperatures[0]; cout << "Enter the wind speed: "; cin >> windSpeeds[0]; cout << "Enter the wind direction: "; cin >> windDirections[0]; numOfReadings++; if(numOfReadings > 4) numOfReadings = 4; break; case 3: //Print the current weather, if valid weather is entered. for(int i = 0; i < numOfReadings; i++) { cout << "*****" << name << "*****" << endl; cout << "Temperature: " << temperatures[i] << endl; cout << "Wind speed: " << windSpeeds[i] << endl; cout << "Wind direction: " << windDirections[i] << endl << endl; } if(numOfReadings == 0) cout << "Please enter the details before asking to print." << endl; break; case 2: if(numOfReadings == 0) { cout << "Please enter the details before asking to print." << endl; break; } cout << "*****" << name << "*****" << endl; cout << "Temperature: " << temperatures[0] << endl; cout << "Wind speed: " << windSpeeds[0] << endl; cout << "Wind direction: " << windDirections[0] << endl << endl; break; case 4: return 0; //Stops execution. default: cout << "Invalid choice. Please follow the menu." << endl; } } }

Please tell me if this program is done correctly and if not make the appropriate corrections. Also, make sure that there are no bugs and that it still runs correctly when hard tested.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Database And Transaction Processing

Authors: Philip M. Lewis, Arthur Bernstein, Michael Kifer

1st Edition

0201708728, 978-0201708721

More Books

Students also viewed these Databases questions

Question

1 . Television News channels importantance of our Life pattern ?

Answered: 1 week ago

Question

1. How is the newspaper help to our daily life?

Answered: 1 week ago

Question

1. Prepare a short profile of Mikhail Zoshchenko ?

Answered: 1 week ago

Question

What is psychology disorder?

Answered: 1 week ago

Question

=+country competitive advantages? Why? Support your point of view.

Answered: 1 week ago

Question

=+from: a) a MNEs perspective? and b) the HRM managers perspective?

Answered: 1 week ago