Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Failure to follow the C++ requirements could reduce the points received from passing the tests. General overview You will be calculating the number of seconds

Failure to follow the C++ requirements could reduce the points received from passing the tests. General overview You will be calculating the number of seconds it will take for sound to travel though a medium. The values you will use are as follows: Medium Speed (feet per second) Air 1,100 Water 4,900 Steel 16,400 Your program will display a menu of three items: Select the medium that sound is traveling through: 1 Air 2 Water 3 Steel After displaying the menu your program will read in the menu item as an unsigned int value . Use a switch statement to process the menu value you have just read in. If the value is invalid (0, or greater than 3) display the following error message: The menu value is invalid. Please run the program again. If the menu value is valid, read in the distance (in feet) that sound will travel in the medium selected. This will look as follows: Enter distance (in feet) The distance value must be read into a variable of type double. If the distance is less than or equal to zero output the message: The distance must be greater than zero If the distance is greater than zero, calculate the speed and output the following (this is for air): Air: 1000.000 ft Traveled for 0.909 seconds Note that the output values have three digits of precision. Here are two sample runs (with input): Run 1: 3 567544.986 Here is the output: Select the medium that sound is traveling through: 1 Air 2 Water 3 Steel Enter distance (in feet) Steel: 567544.986 ft Traveled for 34.606 seconds Run 2: 12 Here is the output: Select the medium that sound is traveling through: 1 Air 2 Water 3 Steel The menu value is invalid. Please run the program again. Failure to follow the requirements for lab lessons can result in deductions to your points, even if you pass the validation tests. Logic errors, where you are not actually implementing the correct behavior, can result in reductions even if the test cases happen to return valid answers. This will be true for this and all future lab lessons. Expected output There are eight tests. Each test will have a new set of input data. You must match, exactly, the expected output. You will get yellow highlighted text when you run the tests if your output is not what is expected. This can be because you are not getting the correct result. It could also be because your formatting does not match what is required. The checking that zyBooks does is very exacting and you must match it exactly. More information about what the yellow highlighting means can be found in course "How to use zyBooks" - especially section "1.4 zyLab basics". Finally, do not include a system("pause"); statement in your program. This will cause your verification steps to fail. Note: that the system("pause"); command runs the pause command on the computer where the program is running. The pause command is a Windows command. Your program will be run on a server in the cloud. The cloud server may be running a different operating system (such as Linux).this is my programm but it is not correct!
#include
#include
using namespace std;
int main()
{
unsigned int choice;
double distance;
cout
cout
cout
cout
cin>>choice;
switch(choice){
case 1:
cout
cin>>distance;
if(distance
cout
break;
}
else
distance = distance *1.0;
cout
cout
break;
case 2:
cout
cin>>distance;
if(distance
cout
break;
}
else
cout
cout
break;
case 3:
cout
cin>>distance;
if(distance
cout
break;
}
else
distance = distance *1.0;
cout
cout
break;
default:
cout
}
}
this is what appers when I run it !
son5part1.cpp: In function int main():
lesson5part1.cpp:24:7: warning: this else clause does not guard... [-Wmisleading-indentation]
else
^~~~
lesson5part1.cpp:26:8: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the else
cout
^~~~
lesson5part1.cpp:38:7: warning: this else clause does not guard... [-Wmisleading-indentation]
else
^~~~
lesson5part1.cpp:40:8: note: ...this statement, but the latter is misleadingly indented as if it is guarded by the else
cout
^~~~
These photos for my output and expected output:
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
image text in transcribed
zyBooks My lbrary>CS 1136 Lab 8:Computer Science Laboratory home > 421. Lab lesson 5 (Part 1of2) E zyBooks catalog Compiler warnings onSparti.cpp: In function 'int main' sonSparti.cpp:24:7: warning: this telse' clause does not guard... I-Wmisleading-indentationl e1se :.epp:26:8: note: ...this statenent, but the latter is nisleadingly cout

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

Step: 3

blur-text-image

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

Statistical And Scientific Database Management International Working Conference Ssdbm Rome Italy June 21 23 1988 Proceedings Lncs 339

Authors: Maurizio Rafanelli ,John C. Klensin ,Per Svensson

1st Edition

354050575X, 978-3540505754

More Books

Students also viewed these Databases questions

Question

5. Identify three characteristics of the dialectical approach.

Answered: 1 week ago