CPSC 121 Assignment 2 solution

$30.00

Original Work ?
Category: You will Instantly receive a download link for .ZIP solution file upon Payment

Description

5/5 - (1 vote)

Goals:
● Demonstrate the appropriate use of floating-point data types
● Perform arithmetic operations with large numbers
● Use constant variables with proper naming conventions
● Practice using proper naming conventions and utilizing comments
Instructions:
● You are tasked with writing a program that will calculate how far we could travel in one
hour at varying fractions of the speed of light.
● The program will display the distance traveled in miles for each percentage below:
○ % 1 the speed of light
○ % 10 the speed of light
○ % 50 the speed of light
○ % 100 the speed of light
● No user input is being used for this assignment
● Your output should roughly match mine below:
Note: cout formats our numbers to shorten them, we will learn how to print numbers nicely later
in the semester. This reads like scientific notation, e.g. 1.60704e+10 is equivalent to
1.60704×10
10
, or 16,070,400,000
Starter Code:
You are provided with a .zip file containing starter code for this assignment. It is set up such that
you should be able to type “make” (without quotes) in the terminal and the program will run.
Be sure to use the proper data types (remember there is a size limitation to data types!), as well
as making the appropriate variables constant with the const keyword. Write good comments
explaining what each step of the logic does where needed (if it’s not readily apparent what
something does, give it a comment!).
Submission:
Submit a single .zip file with your solution to blackboard by the due date. Your .zip file should
have the following:
A folder named “Assignment2”.
Inside that folder: an Assignment2.cpp file, and a Makefile
You should not modify the Makefile. Write your code in Assignment2.cpp.
Rubric:
Program compiles without errors or warnings: 10pts
Output is correct and approximately matches
the example:
10pts
Program uses the “const” keyword where
appropriate
5pts
Program includes sufficient comments,
adheres to good programming style
(indentation, and naming conventions)
5pts
Submission has two files within one folder, all
named correctly
5pts