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++ - MyProgrammingLab
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(Numerical) Heron’s formula for the area, A, of a triangle with sides of length a, b, and c is A=s(sa)(sb)(sc) where s=(a+b+c)2 Write, test, and execute a function that accepts the values of a, b, and c as parameters from a calling function, and then calculates the values of sand[s(sa)(sb)(sc)]. If this quantity is positive, the function calculates A. If the quantity is negative, a, b, and c do not form a triangle, and the function should set A=1. The value of A should be returned by the function.arrow_forwardIf a year has the digit 7 OR the digit 4 in it, then it is called a “Beautiful year”. For example, 2017, 2014, and 2072 are all beautiful years. If the year has BOTH 4 and 7 in it, then it's an “Amazing year”. For example, the years 2047 and 2074 are amazing years. All other years are “Ugly years”. You need to write a function that takes a year as an argument and return it's type. Then, finally print the returned values in the function call. ================================================ Sample Function Call 1: function_name(2470) Sample Output 1: Amazing year ================================================ Sample Function Call 2: function_name(2170) Sample Output 2: Beautiful year ================================================ Sample Function Call 3: function_name(2021) Sample Output 3: Ugly yeararrow_forward
- Make a function which will calculate the pressure of a gas using Van der Waals Equation: The Van der Waals function will have arguments: temperature (T) in Kelvin,molar volume (Vm) in L/mole,critical temperature (Tc) in Kelvin andcritical pressure (Pc) in atm.(Tc and Pc are characteristics of the substance.) Within the function also define the gas constant R= 0.08206 L·atm/mole·K. The Van der Waals equation to calculate the pressure, P is: Where Within the function, create variables a, b and Vc, and calculate the value for each prior to calculating P. Using the MATLAB editor, make a script m-file for the following: Calculate the pressure withTemperatures over the range 255 to 315 K at intervals of 2 K, and Vm = 25.35 L/mole, Consider two substances:For ammonia: Tc = 141.15 K and Pc = 111.5 atm.For carbon dioxide: Tc = 241.9 K and Pc = 73.0 atm. Make a table with temperature in column 1, pressure for carbon dioxide in column 2 and pressure for ammonia in column 3, and write the…arrow_forward3. If you've ever visited Europe (or Canada) you'll know that they tend to measuretemperature in degree Celsius rather than Fahrenheit. Conversion is pretty simple: if f isthe temperature in degree Fahrenheit, then the temperature in degree Celsius isc = (f-32)*5/9.a. Write a function convert() that takes as an input degree Fahrenheit andreturns degree Celsius.>>> convert(32)0.0>>> convert(68)20.0b. Using your function from part a. write a function table() that prints aformatted look-up table that helps your European and Canadian friends figure outthe temperature in Chicago.>>> table()F C-22.0 -30.0-4.0 -20.014.0 -10.032.0 0.050.0 10.068.0 20.086.0 30.0104.0 40.0This question is about the formatting: make sure the temperatures are displayedwith the same precision as shown above and aligned as above.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
- Write 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_forwardA natural number is prime if it is greater than 1 and has no divisors other than 1 and itself.Example: 8 isn't a prime number, as you can divide it by 2 and 4 (we can't use divisors equal to 1 and 8 as the definition prohibits this). On the other hand, 7 is a prime number as we can't find any legal divisors for it.Your task is to write a function checking whether a number is prime or not.The function:•is called IsPrime()•takes one argument (the value to check)•returns True if the argument is a prime number, and False otherwise.Hint: try to divide the argument by all subsequent values (starting from 2) and check the remainder - if it's zero, your number cannot be a prime; think carefully about when you should stop the process.If you need to know the square root of any value you can utilize the ** operator. Remember: the square root of x is the same as x**0.5Python programming question Write a code that calculates all the prime numbers between 1 and 20. (Hint: Use a loop and call the…arrow_forwardThe greatest common divisor (GCD) for a pair of numbers is the largest positive integer that divides both numbers without remainder. For function GCD, write the missing base case condition and action. This function will compute the greatest common divisor of x and y. You can assume that x and y are both positive integers and that x > y. Greatest common divisor is computed as follows:GCD(x, 0) = x and GCD(x, y) = GCD(y, x % y). Examples: GCD(6, 4) -> 2 public int GCD(int x, int y) { if <<Missing base case condition>> { <<Missing base case action>> } else { return GCD(y, x % y); }}arrow_forward
- A natural number is prime if it is greater than 1 and has no divisors other than 1 and itself. Example: 8 isn't a prime number, as you can divide it by 2 and 4 (we can't use divisors equal to 1 and 8 as the definition prohibits this). On the other hand, 7 is a prime number as we can't find any legal divisors for it. Your task is to write a function checking whether a number is prime or not. Please us phython language The function: is called IsPrime() takes one argument (the value to check) returns True if the argument is a prime number, and False otherwise. Hint: try to divide the argument by all subsequent values (starting from 2) and check the remainder - if it's zero, your number cannot be a prime; think carefully about when you should stop the process. If you need to know the square root of any value you can utilize the ** operator. Remember: the square root of x is the same as x**0.5 Write a code that calculates all the prime numbers between 1 and 20. (Hint: Use a loop and…arrow_forwardPyton.Write a function absolute(x) that prints the absolute value of xarrow_forwardWrite a function to determine the cost of an automobile insurance premium, based on driver's age and the number of accidents that the driver has had. The basic insurance charge is $500. There is a surcharge of $100 if the driver is under 25 and an additional surcharge for accidents: \# of accidents Accident Surcharge 1 50 2 125 3 225 4 375 5 575 6 or more 700 Then call the function to print the result. example (underline denotes input values): ```Age? 26``` ```Accidents? 3``` ```$725```arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrCOMPREHENSIVE MICROSOFT OFFICE 365 EXCEComputer ScienceISBN:9780357392676Author:FREUND, StevenPublisher:CENGAGE L