Question
There are two parts to lab lesson 5. The entire lab will be worth 100 points. Bonus points for lab lesson 5 There are also
There are two parts to lab lesson 5. The entire lab will be worth 100 points.
Bonus points for lab lesson 5
There are also 10 bonus points. To earn the bonus points you have to complete the Participation Activities and Challenge Activities for zyBooks/zyLabs unit 4. These have to be completed by the due date for lab lesson 5. For example, if you complete 89% of the activities you will get 8 points (there is no rounding).
Lab lesson 5 part 1 is worth 50 points
For part 1 you will have 40 points if you enter the program and successfully run the program tests. An additional 10 points will be based on the style and formatting of your C++ code.
Style points
The 10 points for coding style will be based on the following guidelines:
Comments at the start of your programming with a brief description of the purpose of the program.
Comments throughout your program
Proper formatting of your code (follow the guidelines in the Gaddis text book, or those used by your CS 1336 professor)
If you have any variables they must have meaningful names.
Development in your IDE
For lab lesson 5 (both parts) you will be developing your solutions using an Integrated Development Environment (IDE) such as Visual Studio, Code::Blocks or Eclipse. You should use whatever IDE you are using for your CS 1336 class. Once you have created and tested your solutions you will be uploading the files to zyBooks/zyLabs. Your uploaded file must match the name specified in the directions for the lab lesson. You will be using an IDE and uploading the appropriate files for this and all future lab lessons.
You will need to develop and test the program in your IDE. Once you are satisfied that it is correct you will need to upload the source file to zyBooks/zyLabs, and submit it for the Submit mode tests. If your program does not pass all of the tests you need to go back to the IDE, and update your program to fix the problems you have with the tests. You must then upload the program from the IDE to zyBooks/zylabs again. You can then run the tests again in Submit mode.
When running your program in Submit mode it is very important that you look at the output from all of the tests. You should then try and fix all of the problems in your IDE and then upload the updated code to zyBooks/zyLabs.
C++ requirements
Your program will read in the menu number as an unsigned int value .
The menu item must be processed using a switch statement.
The distance and all calculations need to be done using double values.
The source file must be named lesson5part1.cpp or zyBooks won't allow you to upload the file.
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".
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started