COSC 1436 Lab 3 The Blue Marble (1)

.pdf

School

Harvard University *

*We aren’t endorsed by this school

Course

1436

Subject

Electrical Engineering

Date

Apr 3, 2024

Type

pdf

Pages

4

Uploaded by ChefHummingbirdPerson1009 on coursehero.com

1 COSC 1436: PROGRAMMING FUNDAMENTALS I Lab 3: The Blue Marble On December 7, 1972, the crew of Apollo 17 took the most famous picture of Planet Earth. It is known as “The Blue Marble” because of its appearance and shape. ( Earth - Wikipedia : https://en.wikipedia.org/wiki/Earth ) While the Earth is not precisely spherical, for our purposes, we will calculate the circumference, surface area and volume of the Earth with the presumption that the Earth’s circumference is a circle and that the Earth’s shape is a sphere. Objectives 1. Input (read) data from keyboard 2. Convert algebraic formulas to programming statements 3. Output (write) results to screen 4. Install & use doctest.h testing framework to check code. doctest.h requires the g++ compiler with a minimum of C++11 standard. Instructions 1. Download zipped Wile 1436_Lab_3.zip from Dropbox and unzip. It contains: a. test_dimensions.cpp (Do not edit) b. doctest.h (Do not edit; compiles when test_dimensions.cpp compiles) 2. Code from scratch a C++ ( .cpp ) Wile having the name: earth_dimensions.cpp 3. Intersperse appropriate comments in the source code: a. Begin line of comment with slash-slash-space (‘ // ’) b. Explaining brieWly what each chunk of code accomplishes c. Cite any source material used, including the given formula sources from calculatorsoup.com 4. Input in miles the polar radius of the earth. The test program provides the input prompt. a. Use the value: 3949.903 b. Note: The radius will appear on the twice, once for input & once for output 5. Declare and initialize PI as a constant double with a value of 3.1415926535898. Figure 1: "The Blue Marble" is a famous photograph of the Earth taken on December 7, 1972, by the crew of the Apollo 17 spacecraft en route to the Moon at a distance of about 29,000 kilometres (18,000 mi). It shows Africa, Antarctica, and the Arabian Peninsula. (https://en.wikipedia.org/wiki/The_Blue_Marbl e#/media/File:The_Earth_seen_from_Apollo_17. jpg)
2 COSC 1436: PROGRAMMING FUNDAMENTALS I 6. Find the circumference of the earth based on the polar radius (presuming that the circumference is a true circle) (source: Circle Calculator (calculatorsoup.com) , https://www.calculatorsoup.com/calculators/geometry-plane/circle.php ) a. ࠵? = 2࠵?࠵? (Wind circumference given the polar radius) 7. Find the surface area of the earth based on the polar radius (presuming that the shape is a sphere) (source: Sphere Calculator (calculatorsoup.com) , https://www.calculatorsoup.com/calculators/geometry-solids/sphere.php ) a. ࠵? = 4࠵?࠵? ! (Wind surface area given the polar radius) 8. Find the volume of the earth based on the polar radius (presuming that the shape is a sphere) (source: Sphere Calculator (calculatorsoup.com) , https://www.calculatorsoup.com/calculators/geometry-solids/sphere.php ) a. ࠵? = " # ࠵?࠵? # (Wind volume given radius) b. Be careful against performing integer division 9. Calculate all values as doubles and set precision to Wive (5) decimal places. 10. print out in order on separate lines (12 lines of text): a. Student FirstName b. Student LastName c. Student’s Blinn username (including two digit sufWix, e.g., ‘Wirst.last00’) d. Course number (number only, without ‘COSC’): 1436 e. Section : N01 , 102 , 103 , R03 or R11 f. Lab name : The Blue Marble g. Radius in miles ( input ted value only, no label) h. Circumference in miles (calculated within $ $%%% % precision, no label) i. Surface area in square miles (calculated within $ $%%% % precision, no label) j. Volume in cubic miles (calculated within $ $%%% % precision, no label) k. URL citation as a single string from CalculatorSoup formulas for circle : l. URL citation as a single string from CalculatorSoup formulas for sphere : 11. Compile and execute test_dimensions.cpp : a. Compile with (copy & paste) the following command line instruction (CLI): i. g++ -std=c++11 -Wall -Werror test_dimensions.cpp -o lab3test b. Execute with the following CLI: ./lab3test -s . It will: i. check your code ( earth_dimensions.cpp ) for syntax errors, and ii. execute the compiled version, checking for runtime errors & accuracy iii. -s option outputs all test (with results) to screen c. Goal: pass all twelve (12) assertions d. Note: Compile test_dimensions.cpp only one time; execute ./lab3test -s each time earth_dimensions.cpp is edited & saved.
Your preview ends here
Eager to read complete document? Join bartleby learn and gain access to the full version
  • Access to all documents
  • Unlimited textbook solutions
  • 24/7 expert homework help