The gravitational attractive force between two bodies with masses m1 and m2 separated by a distance d is given by:
F=G m 1 m 2 d 2
where G is the universal gravitational constant:
G=6.673× 10 – 8(cm 3 g× sec 2)
Write a function definition that takes arguments for the masses of two bodies and the distance between them and that returns the gravitational force. Since you will use the preceding formula, the gravitational force will be in dynes. One dyne equals
(g×cm sec 2)
You should use a globally defined constant for the universal gravitational constant. Embed your function definition in a complete
Want to see the full answer?
Check out a sample textbook solutionChapter 4 Solutions
Problem Solving with C++ (10th Edition)
Additional Engineering Textbook Solutions
Web Development and Design Foundations with HTML5 (8th Edition)
Computer Systems: A Programmer's Perspective (3rd Edition)
Software Engineering (10th Edition)
Starting out with Visual C# (4th Edition)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Introduction to Java Programming and Data Structures, Comprehensive Version (11th Edition)
- (Statics) An annulus is a cylindrical rod with a hollow center, as shown in Figure 6.7. Its second moment of inertia is given by this formula: I4(r24r14) I is the second moment of inertia (m4). r2 is the outer radius (m). r1 is the inner radius (m). a. Using this formula, write a function called annulusMoment ( ) that accepts two double-precision numbers as parameters (one for the outer radius and one for the inner radius), calculates the corresponding second moment of inertia, and displays the result. b. Include the function written in Exercise 5a in a working program. Make sure your function is called from main(). Test the function by passing various data to it.arrow_forward(Statics) A beam’s second moment of inertia, also known as its area moment of inertia, is used to determine its resistance to bending and deflection. For a rectangular beam (see Figure 6.6), the second moment of inertia is given by this formula: Ibh3/12 I is the second moment of inertia (m4). b is the base (m). h is the height (m). a. Using this formula, write a function called beamMoment() that accepts two double- precision numbers as parameters (one for the base and one for the height), calculates the corresponding second moment of inertia, and displays the result. b. Include the function written in Exercise 4a in a working program. Make sure your function is called from main(). Test the function by passing various data to it.arrow_forwardNote: You may NOT use the MATLAB functions primes 0 or isprime( in your solution! Write a function that returns all prime numbers up to a specified value. For example, calling p=primes UpTo(20) should produce:arrow_forward
- Re-write the following function so that a given XAND return the value of f(x).arrow_forwardTo find area of triangle, square, circle and rectangle using function overloadingarrow_forwardWrite the definition of a function that takes as input three numbers. The function returns true if the floor of the product of the first two numbers equals the floor of the third number; otherwise it returns false. (Assume that the three numbers are of type double.)arrow_forward
- Write definitions for these functions:sphereArea(radius) Returns the surface area of a sphere having thegiven radius. sphere Volume (radius) Returns the volume of a sphere having the givenradius. Use your functions to solve Programming Exercise 1 from Chapter 3.arrow_forwardWrite a function that calculates the speed of sound (a) in air of a given temperature T (Fahrenheit) which is passed as parameter and returns the speed. Be sure your function does not lose the fractional part of the quotient in the formula shown. Formula to compute the speed in ft/sec: Alpha (α)=1086 sqrt((5T+297)/(247);arrow_forwardDetermine names for functions that do the following: Find the average of a set of numbers.arrow_forward
- In a particular jurisdiction, taxi fares consist of a base fare of $4.00, plus $0.25 for every 140 meters travelled. There are no "partial" travel charges, so the $0.25 is only applied if the passenger is taken to the 140-meter threshold. Some examples: if a passenger only travels 139 meters, the fare will be $4.00. If the passenger travels 279 meters, the fare will be $4.25. Write a function called fare() that takes the distance travelled (in miles) as its only parameter and returns the total fare as its only result. We are providing our test suite (test_fare.py) so you can test your code against a portion of the test framework we'll use to validate your solution.arrow_forwardIt is estimated that a restaurant's tip box accumulates twice as much as the previous day. Write the function with the main () function that takes the number of days as a parameter and returns the total tip amount on the day entered in the restaurant with a 10-TL tip on the first day. Sample Work: Enter the number of days: 4 --------------------------------- Total estimated stake in the box: 150.00 -TL in carrow_forwardThe velocity v and the falling distance d as a function of time of a skydiver that experience the air resistance can be approximated by: and d() = " in cosh :) kg v(t) = mg tanh where k = 0.24 Kg is a constant, m is the skydiver mass, g = 9.81 " is the acceleration due to gravity, and t is the time in seconds since the skydiver starts falling. Write m MATLAB code to determine the velocity v and the falling distance d at t = 8s for a 95kg skydiver. • Note: Velocity v and distance d are each worth 50% of the total points for this problem. Script e C Reset I MATLAB Docume 1 % Define variable(s) here. 3 v = % write the equation for v here, do not change the variable name. 4 d = % write the equation for d here, do not change the variable name.arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr