Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

4.19 Lab Lesson 4 (Part 1 of 2) Part of lab lesson 4 There are two parts to lab lesson 4. The entire lab will

4.19 Lab Lesson 4 (Part 1 of 2)

Part of lab lesson 4

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

Lab lesson 4 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 4 (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

Calculations should be done with type double.

You must use const double values for the acceleration due to gravity on the Earth, the Moon and on Venus.

The filename for your program must be lesson4part1.cpp. The zyBooks environment will not let you upload the source file if it has a different file name.

General overview

You need to write a program that reads in the mass of an object (in kg) and output the weight (in N) on the Earth, on the Moon, and on Venus.

An object's mass can be measured in kilograms. The weight is measured in newtons. So an object of a specific mass (in kilograms) would have one weight (in newtons) on the earth and a different weight on the moon. Your program will read in the mass (in kilograms) and convert it to newtons for the Earth, the Moon, and Venus.

So, on the Earth we can convert kilograms to newtons with the following expression:

weight = mass * 9.81

where 9.81 is the acceleration due to gravity on earth (in meters per second squared or m/s^2).

On the Moon this formula would be:

weight = mass * 1.62

where 1.62 is the acceleration due to gravity on the moon (m/s^2)

Finally, for Venus it would be:

weight = mass * 8.87

Again, all of the above assume the mass is in kilograms (kg) and the weight is in newtons (N).

If the weight on the earth is greater than or equal to 1500 newtons output a message saying the object is heavy.

If the weight on the earth is less than 5 newtons say it is light.

The mass and weight should use fixed notation with a precision of 4 digits to the right of the decimal point. The 1st column has a width of 8 characters and the 2nd column has a width of 14 characters. The 1st column is left justified and the 2nd column is right justified.

Use double variables and constants in your calculations.

The acceleration values must be defined as const double values. These are the 9.81, 1.62 and 8.87 values from above.

If the mass is less than or equal to 0 output a message saying the mass must be greater than 0.

See the sample output below for the exact syntax of the messages.

For example, assume the input is:

101.9367991 

The output will be as follows:

The mass is 101.9368 kg Location Weight (N) Earth 1000.0000 Moon 165.1376 Venus 904.1794 

Another example is when the object is light:

0.50 

The output will be as follows:

The mass is 0.5000 kg Location Weight (N) Earth 4.9050 Moon 0.8100 Venus 4.4350 The object is light 

Here is the case where the value is too heavy:

155 

With output:

The mass is 155.0000 kg Location Weight (N) Earth 1520.5500 Moon 251.1000 Venus 1374.8500 The object is heavy 

Finally, we have the case where the mass is invalid:

-20.5 

With output:

The mass is -20.500 kg The mass must be greater than zero 

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.

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

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

What is the purpose of the Salary Structure Table?

Answered: 1 week ago

Question

What is the scope and use of a Job Family Table?

Answered: 1 week ago