2023 Part of lab lesson 8 There are two parts to lab lesson 8 | Assignment Collections

Computer Science 2023 Lab Lesson 8 Part 1

2023 Part of lab lesson 8 There are two parts to lab lesson 8 | Assignment Collections

 

Part of lab lesson 8

There are two parts to lab lesson 8. The entire lab will be worth 100 points.

Lab lesson 8 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 8 (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.

For this and all future labs the name of the source files must be:

lessonXpartY.cpp

Where X is the lab lesson number (8 for lab lesson 8) and Y is the part number (1 for part 1, 2 for part 2).

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

You are not allowed to use any global variables. Use of global variables will result in a grade of zero for part 1. Global variables are those that are declared outside the scope of any function. See the Gaddis text book for more details.

Make sure you exactly match any function signatures that are required by the exercise. The function signatures are:

double readSeconds()
double calculateEarthDistance(double seconds)
double calculateMoonDistance(double seconds)
void displayResults(double seconds, double earthDistance, double moonDistance)

The program must use type double for calculations.

Failure to follow the C++ requirements could reduce the points received from passing the tests.

General overview

Your program will calculate the distance an object travels (in meters) on Earth for a specified number of seconds. You will also calculate the distance traveled on the Moon (in meters) for the specified number of seconds.

Your program must have the main function and, at least, the following four additional functions. The signatures for these functions must be as follows:

double readSeconds()
double calculateEarthDistance(double seconds)
double calculateMoonDistance(double seconds)
void displayResults(double seconds, double earthDistance, double moonDistance)

The readSeconds function will be an input function that will read in a double value from cin and return that value back to main.

The calculateEarthDistance function will calculate the distance an object falls (on Earth) during the specified number of seconds.

The calculateMoonDistance function will calculate the distance an object falls (on the Moon) during the specified number of seconds.

The displayResults function that will display the number of seconds an object has fallen as well as the distance the object has fallen on the Earth and on the Moon.

You can have additional function is needed.

Here is a summary of the processing that is required in the various functions:

double readSeconds()

This function reads in a value from cin. If the value is less than zero the function should output a message.

The value read in (valid or not) should be returned to the calling function.

The prompt from the function should be:

Enter the time (in seconds)

If the value is less than zero you should output the following message.

The time must be zero or more

double calculateEarthDistance(double seconds)

This function calculates the distance traveled (on Earth) during the number of seconds pass in as a parameter. The distance is calculated in meters and is returned to the calling function.

The formula is:

d = 0.5 * g * pow(t, 2)

Where d is distance (in meters), t is time (in seconds) and g is 9.8 meters / second squared (the acceleration due to gravity on the earth).

Use good variable names and not just d, g and t. Use double values for your calculations.

double calculateMoonDistance(double seconds)

This function calculates the distance traveled (on the Moon) during the number of seconds pass in as a parameter. The distance is calculated in meters and is returned to the calling function.

The formula is the same as the formula on Earth, but the value of g is different. For the Moon g is 1.6 meters / second squared.

Use good variable names and not just d, g and t. Use double values for your calculations.

void displayResults(double seconds, double earthDistance, double moonDistance)

The displayResults function takes three parameters of type double. The first is the number of seconds and the second is the distance traveled on the Earth, and the third parameter is the distance traveled on the Moon. Note that the displayResults function must be passed the values for seconds, earthDistance, and moonDistance. The displayResults function MUST NOT call readSeconds, calculateEarthDistance, or calculateMoonDistance.

The output is the text:

The object traveled xxx.xxxx meters in zz.zz seconds on Earth
The object traveled yy.yyyy meters in zz.zz seconds on the Moon

Note that the distance is output with four digits to the right of the decimal point while seconds is output with two digits to the right of the decimal point. Both are in fixed format.

Assume that the number of seconds is 10.5, the output would be:

The object traveled 540.2250 meters in 10.50 seconds on Earth
The object traveled 88.2000 meters in 10.50 seconds on the Moon

int main()

The main function will be the driver for your program.

First you need a loop that will process input values until you get an input value that is equal to 0. You will get this input value by calling the readSeconds function.

If the value is greater than zero the main function needs to call the calculateEarthDistance, calculateMoonDistance, and displayResults functions.

If the value is less than zero the loop should end and your program should then end.

Note that all of the required non-main functions are called from main.

For the following sample run assume the input is as follows:

-12.5
-3.5
10.5
4.2
0

Your program should output the following:

Enter the time (in seconds)
The time must be zero or more
Enter the time (in seconds)
The time must be zero or more
Enter the time (in seconds)
The object traveled 540.2250 meters in 10.50 seconds on Earth
The object traveled 88.2000 meters in 10.50 seconds on the Moon
Enter the time (in seconds)
The object traveled 86.4360 meters in 4.20 seconds on Earth
The object traveled 14.1120 meters in 4.20 seconds on the Moon
Enter the time (in seconds)

Note that a zero is used to terminate the loop, but a value of zero is actually a valid value for seconds. We just aren’t using that value in this program.

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 seven tests.

The first three tests will run your program with input and check your output to make sure it matches what is expected.

The next three tests are unit tests.

The unit tests are programs that have been written that will call your calculateEarthDistance and calculateMoonDistance functions to make sure it is correctly processing the arguments and generating the correct replies.

The unit tests will directly call the calculateEarthDistance and calculateMoonDistance functions. The compilation of the unit tests could fail if your calculateEarthDistance and calculateMoonDistance functions do not have the required signatures.

The unit tests will also test any results to make sure you have followed the directions above.

The last test will only have invalid data to make sure your program works properly in that environment.

For the output tests (the first three tests and the last test) 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).

Error message “Could not find main function”

Now that we are using functions some of the tests are unit tests. In the unit tests the zyBooks environment will call one or more of your functions directly.

To do this it has to find your main function.

Right now zyBooks has a problem with this when your int main() statement has a comment on it.

For example:

If your main looks as follows:

int main() // main function

You will get an error message:

Could not find main function

You need to change your code to:

// main function
int main()

If you do not make this change you will continue to fail the unit tests.

 

We give our students 100% satisfaction with their assignments, which is one of the most important reasons students prefer us to other helpers. Our professional group and planners have more than ten years of rich experience. The only reason is that we have successfully helped more than 100000 students with their assignments on our inception days. Our expert group has more than 2200 professionals in different topics, and that is not all; we get more than 300 jobs every day more than 90% of the assignment get the conversion for payment.

Place Order Now

#write essay #research paper #blog writing #article writing #academic writer #reflective paper #essay pro #types of essays #write my essay #reflective essay #paper writer #essay writing service #essay writer free #essay helper #write my paper #assignment writer #write my essay for me #write an essay for me #uk essay #thesis writer #dissertation writing services #writing a research paper #academic essay #dissertation help #easy essay #do my essay #paper writing service #buy essay #essay writing help #essay service #dissertation writing #online essay writer #write my paper for me #types of essay writing #essay writing website #write my essay for free #reflective report #type my essay #thesis writing services #write paper for me #research paper writing service #essay paper #professional essay writers #write my essay online #essay help online #write my research paper #dissertation writing help #websites that write papers for you for free #write my essay for me cheap #pay someone to write my paper #pay someone to write my research paper #Essaywriting #Academicwriting #Assignmenthelp #Nursingassignment #Nursinghomework #Psychologyassignment #Physicsassignment #Philosophyassignment #Religionassignment #History #Writing #writingtips #Students #universityassignment #onlinewriting #savvyessaywriters #onlineprowriters #assignmentcollection #excelsiorwriters #writinghub #study #exclusivewritings #myassignmentgeek #expertwriters #art #transcription #grammer #college #highschool #StudentsHelpingStudents #studentshirt #StudentShoe #StudentShoes #studentshoponline #studentshopping #studentshouse #StudentShoutout #studentshowcase2017 #StudentsHub #studentsieuczy #StudentsIn #studentsinberlin #studentsinbusiness #StudentsInDubai #studentsininternational