Sale!

COSC 2347: Homework 1

$30.00 $18.00

Category: You will Instantly receive a download link for .zip solution file upon Payment || To Order Original Work Click Custom Order?

Description

5/5 - (3 votes)

PROGRAM DESCRIPTION:
The purpose of this programming project is to write a C++ program to calculate the
effect of gravity on a projectile (i.e., an object) that is thrown, shot, or dropped. More
specifically, the height of an object propelled directly upward from an initial height 𝑠𝑠0 at
an initial velocity 𝑣𝑣0 is given by
𝑆𝑆(𝑑𝑑) = βˆ’16𝑑𝑑
2 + 𝑣𝑣0𝑑𝑑 + 𝑠𝑠0,
where 𝑣𝑣0 is in feet/second and 𝑠𝑠0 is in feet. The maximum height (at the vertex) can be
found at the coordinates:
οΏ½
βˆ’π‘π‘
2π‘Žπ‘Ž , 𝑓𝑓 οΏ½βˆ’π‘π‘
2π‘Žπ‘ŽοΏ½οΏ½ = οΏ½
βˆ’π‘π‘
2π‘Žπ‘Ž ,
βˆ’π‘π‘2+4π‘Žπ‘Žπ‘Žπ‘Ž
4π‘Žπ‘Ž οΏ½.
Visually, you may view the height of the object over time by the following graph:
Using the quadratic equation π‘₯π‘₯ = βˆ’π‘π‘Β±βˆšπ‘π‘2βˆ’4π‘Žπ‘Žπ‘Žπ‘Ž
2π‘Žπ‘Ž , you are to calculate how long it takes
the projectile to hit the ground, as defined by the zero, or π‘₯π‘₯-intercept, of the equation
(see above diagram). Additionally, you are to calculate the maximum height the object
attains using the formula for the coordinates given above.
REQUIREMENTS:
β€’ As with all homework programs in this course, your program’s output initially
display the department and course number, your name, your SamID, and your
e-mail address.
β€’ You will declare the gravitational constant (i.e., the -16 in the height formula) as a
local constant using the appropriate naming conventions.
β€’ You will prompt the user for and read in the initial height s0 and the initial
velocity v0 as floating point numbers.
COSC 2347: Homework 1
2
β€’ You will calculate the number of seconds the projectile takes to hit the ground,
rounded to two decimal places.
β€’ You will calculate the object’s maximum height attained, rounded to two decimal
places.
β€’ You will print out these results (the time and maximum height) to the screen,
along with a meaningful message.
β€’ Your code should be well documented in terms of comments. For example, good
comments in general consist of a header (with your name, course section, date,
and brief description), comments for each variable, and commented blocks of
code.
β€’ Your program source code should be named β€œhomework1.cpp”, without the
quotes.
β€’ Your program will be graded based largely on whether it works correctly on the
Linux machines , so you should make sure that your program compiles and runs
on a Linux machine.
β€’ This is an individual programming assignment that must be the sole work of the
individual student.
You may assume that all input will be of the appropriate data type, so no error checking
needs to be done. Additionally, consider the possibility that you may have two solutions
(i.e., π‘₯π‘₯-intercepts) to the number of seconds it takes for the object to hit the ground, but
only one of them (which one?) is valid – only print out the valid solution.
DESIGN (ALGORITHM):
On a piece of paper (or word processor), write down the algorithm, or sequence of
steps, that you will use to solve the problem. You may think of this as a β€œrecipe” for
someone else to follow. Continue to refine your β€œrecipe” until it is clear and
deterministically solves the problem. Be sure to include the steps for prompting for
input, performing calculations, and displaying output.
You should attempt to solve the problem by hand first (using a calculator as needed) to
work out what the answer should be for a few set of inputs.
Type these steps and calculations into a document (i.e., Word, text, PDF) that will be
submitted along with your source code. Note that if you do any work by hand, images
(such as pictures) may be used, but they must be clear and easily readable. This
document shall contain both the algorithm and any supporting hand-calculations you
used in verifying your results.
COSC 2347: Homework 1
3
SAMPLE OUTPUT (input shown in bold green):
+———————————————-+
| Computer Science |
| CSCE 2347 – Special Topics |
| Student Name SamID email:
+———————————————-+
Enter initial height of s0 in feet: 80
Enter initial velocity of v0 in feet/sec: 32
The projectile will hit the ground in 3.45 seconds.
The maximum height the object will reach is 96.00 feet.
TESTING:
Test your program to check that it operates as desired with a variety of inputs (both
integral numbers as well as floating-point numbers). Then, compare the answers your
code gives with the ones you get from hand calculations.
SUBMISSION:
Your program will be graded based largely upon whether it works correctly on the Linux
machines, so you should make sure your program compiles and runs on the Linux
machines.
Your program will also be graded based upon your program style. This means that you
should use comments (as directed), meaningful variable names, and a consistent
indentation style as recommended in the textbook and in class.
We will be using an electronic homework submission on Blackboard to make sure that
all students hand their programming projects on time. You will submit both (1) the
program source code file and (2) the algorithm design document to the Homework 1
dropbox on Blackboard by the due date and time.
Note that this project must be done individually. Program submissions will be checked
using a code plagiarism tool against other solutions, so please ensure that all work
submitted is your own.
Note that the dates on your electronic submission will be used to verify that you met the
due date and time above. All homework up to 24 hours late will receive a 50% grade
penalty. Later submissions will receive zero credit, so hand in your best effort on the
due date.