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++ (9th 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) 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_forward(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_forwardRedo the program given where you have to define and use the following functions: (a) isTriangle - takes 3 sides of a triangle and returns true if they form a triangle, false otherwise. (b) isIsosceles - takes 3 sides of a triangle and returns true if they form an isosceles triangle, false otherwise. (c) isEquilateral - takes 3 sides of a triangle and returns true if they form anequilateral triangle, false otherwise. (d) isRight - takes 3 sides of a triangle and returns true if they form a right triangle, false otherwise. (e) your program should run continuous until the user wants to quit The given program: #include <iostream> #include <cmath> using namespace std; // Constant Declarations const double E = .0001; int main() { double side1, side2, side3; bool isTriangle, isRight, isEquilateral, isIsosceles; cout << "Enter the lengths of the 3 sides of a triangle -- "; cin >> side1 >> side2 >> side3; isTriangle = side1 + side2 > side3 &&side1…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 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_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_forwardDetermine names for functions that do the following: Find the average of a set of numbers.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_forward
- Write 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. For each of the following functions, indicate how much the function’s valuewill change if its argument is increased fourfold.a. log2 n b. √n c. n d. n2 e. n3 f. 2narrow_forwardWrite a function to determine the resultant force vector R of the two forces F₁ and F2 applied to the bracket, where 0₁ and 02. Write R in terms of unit vector along the x and y axis. R must be a vector, for example R = [Rx, Ry]. The coordinate system is shown in the figure below: F₁ y 0₂ 0₁ F2arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr