### Wrong standard output?

Hi guys, this is a question from my homework:

The speed of sound depends on the material the sound is passing through. Below is the approximate speed of sound (in feet per second) for air, water and steel:
air: 1,100 feet per second
water: 4,900 feet per second
steel: 16,400 feet per second
Write a program that displays a menu allowing the user to select air, water, or steel. After the user has made a selection, he or she should be asked to enter the distance a sound wave will travel in the selected medium. The program will then display the amount of time it will take.

Menu. The menu should look exactly like this:
Select a medium: 1. Air 2. Water 3. Steel

Prompts And Output Labels. After the user chooses the medium, prompt for distance simply with the string "Enter the distance: ". After each calculation, your output should be of the form "A sound wave takes T seconds to travel D feet in M." where T is the time you calculated to 4 digits of precision, D is the distance entered and M is the medium (air/water/steel) selected.

Input Validation. The program should validate both the menu choice and the distance entered. If the menu choice is not 1 or 2 or 3 then the program prints "The valid choices are 1 through 3. Run the program again and select one of those." and terminates. The distance must not be negative-- otherwise the program prints out the message "Distance must be greater than zero." and terminates.

 ``12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152`` ``````#include #include using namespace std ; int main () { const int A = 1100; const int W = 4900; const int S = 16400; double distance; int choice; cout << "Select a medium:\n"; cout << "1. Air\n"; cout << "2. Water\n"; cout << "3. Steel\n"; cout << "\n"; cout << "Enter your choice: "; cin >> choice; if (choice > 0 && choice < 4) { cout << "Enter the distance: \n"; cin >> distance; if (distance > 0) { cout << "A sound wave takes "; cout << fixed << setprecision(4); switch (choice) { case 1: cout << distance / A << " seconds to travel " << distance << " feet through air.\n"; break; case 2: cout << distance / W << " seconds to travel " << distance << " feet through water.\n"; break; case 3: cout << distance / S << " seconds to travel " << distance << " feet through steel.\n"; break; } } else { cout << "Distance must be greater than zero."; } } else { cout << "The valid choices are 1 through 3. Run the program again and select one of those."; } return 0; }``````

This is the code that I entered, sorry if it's messy. It says "Standard output was not expected". What does this mean? I tested this in Visual Studio and there wasn't anything wrong. :O
Did you have to submit this via an online validation service?

Just wondering, as the question reads:
Menu. The menu should look exactly like this:
 ```Select a medium: 1. Air 2. Water 3. Steel Enter your choice:```

However the actual output looks like this:
 ```Select a medium: 1. Air 2. Water 3. Steel Enter your choice: ```
The text is the same, but the layout differs. An online validator may reject that.

There may also be differences in expected appearance of the other output.
For example, compare this:
 `A sound wave takes 112233.4445 seconds to travel 123456789.0000 feet through air.`

with this:
 ```A sound wave takes 1.122e+005 seconds to travel 123456789 feet through air. ```
I may be in the wrong track here. However, going back to the question, it reads:"where T is the time you calculated to 4 digits of precision, D is the distance entered" and for example 112233.4445 has 10 digits of precision rather than the specified 4.

Sounds very finicky but in real world programming such issues are just as much a part of a "correct" answer as doing the maths right.
Topic archived. No new replies allowed.