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_forwardTo find area of triangle, square, circle and rectangle using function overloadingarrow_forward
- My v and d are incorrect, please write them correctlyarrow_forwardDetermine names for functions that do the following: Find the average of a set of numbers.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
- It 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. 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_forwardThe great circle distance is the distance betweentwo points on the surface of a sphere. Let (x1, y1) and (x2, y2) be the geographicallatitude and longitude of two points. The great circle distance between the twopoints can be computed using the following formula:d = radius X arccos(sin (x1) X sin(x2) + cos(x1) X cos(x2) X cos(y1 - y2))Write a program that prompts the user to enter the latitude and longitude of twopoints on the earth in degrees and displays its great circle distance. The averageradius of the earth is 6,371.01 km. Note you need to convert the degrees into radiansusing the Math.toRadians method since the Java trigonometric methods useradians. The latitude and longitude degrees in the formula are for north and west.Use negative to indicate south and east degrees. Here is a sample run: Enter point 1 (latitude and longitude) in degrees: 39.55 −116.25 ↵EnterEnter point 2 (latitude and longitude) in degrees: 41.5 87.37 ↵EnterThe distance between the two points is…arrow_forward
- : Given a boolean expression consisting of the symbols 0 (false), 1 (true), & (AND), I (OR), and / (XOR), and a desired boolean result value result, create a function that counts the number of ways the expression may be parenthesized such that it evaluates to result. The expression should be completely parenthesized (for example, (0) A(1)) but not excessively (for example, (((0)) / (1))).EXAMPLE \scountEval("l/01011", false) yields 2 counts."0&0&0&1All0", true) = 10arrow_forwardPlease explain how to write an expression for the function in the image. Thank you.arrow_forwardTo convert between Celsius and Fahrenheit, the following formula is used, where C = Celsius temperature and F = Fahrenheit temperature: C = 5/9 * (F-32) Write a C++ temperature conversion program which does the following: Write a function called toCelsuis which takes a Fahrenheit temperature as a parameter, and returns the equivalent Celsius temperature: float toCelsius(float) Demonstrate that your function works by writing a main() function that prints out a conversion table. It should have Fahrenheit values 60, 61, 62, ... through 80 (21 temperatures in total) and should also have the corresponding Celsius temperatures that your function calculated. So your output should look something like this (with 21 temperature conversions total, I used ... to save space here for most of them): Welcome to the temperature table!F C60 15.661 16.1... ...80 26.7 If you like: you can add this line in your function to make floating point output fixed, make sure you…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr