I have bits and pieces of code that I think are correct, but I don't know how to fill in the remaining pieces. Any help would be appreciated.
Here's the assignment:
Code
HW4. Input Conditioning for an Aircraft Simulator
Devise a program to takes user inputs for a flight simulator and checks their validity until prompted to exit.
Given Variables:
1) char menuChoice -- Input by user. Allowable options defined in the following table:
'A' -> increase velocity
'B' -> decrease velocity
'C' -> increase altitude
'D' -> decrease altitude
'E' -> increase velocity and altitude
'F' -> decrease velocity and altitude
'0' -> exit
2) double velocityChange -- Input by user. Allowable range is 0.1 to 100.0
3) double altitudeChange -- Input by user. Allowable range is 200.0 to 10000.0
4) double currentVelocity -- Internal value. Allowable range is 0.0 to 650.0 and initial condition is 0.0
5) double currentAltitude -- Internal value. Allowable range is -200.0 to 40000.0 and initial condition is 1000.0
Note: ensure your program provides protection against mishandling of user and program variables (remember scope and safety)
Write main and the functions for the following actions to take user input and continuously adjust velocity and altitude until the user exits or a fault condition occurs:
1) Handle user inputs for the following variables: char menuChoice, double velocity, double altitude. If no valid input choice, keep asking until one is provided.
2) Check validity of user velocity input and return new currentVelocity based on increase/decrease as appropriate. Exit with a message if user input violates the currentVelocity range.
3) Check validity of user altitude input and return new currentAltitude based on increase/decrease as appropriate. Exit with a message if user input violates the currentAltitude range.
If the user chooses to exit provide a message to that effect. For all exit cases print the currentVelocity and current Altitude (ensuring the fault condition was not applied).
Here's what I have so far
Code
int main()
{
cout << "To increase velocity, press A. \n";
cout << "To decrease velocity, press B. \n";
cout << "To increase altitude, press C. \n";
cout << "To decrease altitude, press D. \n";
cout << "To increase velocity and altitude, press E. \n";
cout << "To decrease velocity and altitude, press F. \n";
cout << "To exit, press 0. \n";
Code
while( velocityChange < 0.1 || velocityChange > 100){
cin >> velocityChange;
}
while ( altitudeChange < 200.0 || altitudeChange > 10000.0){
cin >> altitudeChange;
}
while ( currentVelocity < 0.0 || currentVelocity > 650.0){
cin >> currentVelocity;
}
while ( currentAltitude < -200.0 || currentAltitude > 40000.0){
cin >> currentAltitude;
}
I don't know how to define the variables and how to execute what the program is requiring