Question
This is a two-part lab. In part A, you will use existing C/C++ library functions to solve a simple scientific problem. In part B you
This is a two-part lab.
In part A, you will use existing C/C++ library functions to solve a simple scientific problem. In
part B you will take a problem description and solve it using, in part, a function you design and
implement.
Specifications:
Part A This part looks a including Functions in your program
Write a program that outputs the range of a projectile. The formula for computing this range is:
range = sin(2.0 * angle) * velocity2 / gravity
where:
angle = the angle of the projectiles path (in radians)
velocity = the initial velocity of the projectile (in meters-per-second)
gravity = the earths constant acceleration due to gravity of 9.8 meters-persecond-
per-second
range = the projectiles range (in meters)
The takeoff angle must be input by the user of your program in degrees (0 to 90) so you must
convert this angle to its radian equivalent. This is necessary because the trigonometric functions,
sin(x), cos(x), etc., require an angle argument (parameter) expressed in radians. The expression
for converting an angle in degrees to its equivalent in radians is:
Angle(in radians) = angle(in degrees) * p/180.0
where the universal constant, p, to 7 places of accuracy is:
p = 3.1415926
So, for example, an angle of 45o would become,
45 * 3.1415926 / 180.0 = 0.7853975 radians.
Your interactive input followed by your computed range output should look something like this:
Takeoff Angle (in degrees):
Initial Velocity (meters per second):
Projectile Range (in meters):
The C/C++ predefined library,
and the exponent operation (pow). You will need to open the
use these functions (i.e., what parameter(s) they require, what the type(s) of these parameters are,
and the type of the value returned).
As a minimum, test your program with the following test cases (NOTE: Your program
does NOT need to display these in the table form shown below)::
Takeoff Angle Initial Velocity Range
30 100
30 200
45 100
45 200
60 100
60 200
90 100
90 200
Part B
Solve problem 6.12 on page 273 of your text. For your solution to this problem the
function, calculateCharges(), specified in the problem description, must be implemented
in (a) separate file(s) for the file containing the main() function that calls this function
(multiple times).
One sample output looked like this:
Car Hours Charge
1 1.5 $2
2 4 $2.5
3 24 $10
TOTAL 29.5 $14.5
Test this program with at least three (3) sets of input data
Deliverable(s):
Turn in the source listings of the programs you develop for both parts of this lab and the results
you get from running the programs against the test cases specified above. Be sure to properly
document your programs per the specifications in the previous labs. By now you should be getting a
feel for what information is necessary for fellow programmers who need to read and understand your
programs purpose and how it accomplishes the job.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started