Concept explainers
The gravitational attractive force between two bodies with masses
where G is the universal gravitational constant:
Write a function definition that takes arguments for the masses of two bodies and the distance between them and returns the gravitational force between them.
Since you will use the previous formula, the gravitational force will be in dynes. One dyne equals a
You should use a globally defined constant for the universal gravitational constant. Embed your function definition in a complete
Trending nowThis is a popular solution!
Chapter 3 Solutions
ABSOLUTE C++ -TEXT
Additional Engineering Textbook Solutions
Management Information Systems: Managing The Digital Firm (16th Edition)
Computer Science: An Overview (13th Edition) (What's New in Computer Science)
Java: An Introduction to Problem Solving and Programming (8th Edition)
Database Concepts (8th Edition)
Web Development and Design Foundations with HTML5 (8th Edition)
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
- Solve quickarrow_forwardRe-write the following function so that a given XAND return the value of f(x).arrow_forward5. Write a function harmonic that will take an integer n as a parameter and return the result of the harmonic series: Γράψτε μια συνάρτηση harmonic που θα πάρει έναν ακέραιο η ως παράμετρο και θα επιστρέψει το αποτέλεσμα της αρμονικής σειράς: 1 1 -+-+-+ 3 + 2 For example, harmonic (2) = 1.5 and harmonic (3) = 1.833arrow_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_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_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_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_forwardWrite a function that returns the average speed traveled given an uphill time, uphill rate and a downhill rate. Uphill time is given in minutes. Return the rate as an integer (mph). No rounding is necessary. Examples aveSpd (18, 20, 60) - 30 aveSpd (30, 10, 30) - 15arrow_forwardWrite a function that computes the area of a triangle given the length of itsthree sides as parameters (see Programming Exercise 9 from Chapter 3).Use your function to augment triangle2 . py from this chapter so that italso displays the area of the triangle.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_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_forwardA prime number is a number that is only evenly divisible by itself and 1. For example, the number 5 is prime because it can only be evenly divided by 1 and 5. The number 6, however, is not prime because it can be divided evenly by 1, 2, 3, and 6. Design a Boolean function called isPrime, that accepts an integer as an argument and returns True if the argument is a prime number, or False otherwise. Use the function in a program that prompts the user to enter a number and then displays a message indicating whether the number is prime. The following modules should be written: getNumber, that accepts a Ref to an integer, prompts the user to enter a number, and accepts that input isPrime, that accepts an integer as an argument and returns True if the argument is a prime number, or False otherwise showPrime, that accepts an integer as an argument , calls isPrime, and displays a message indicating whether the number is prime The main module, that will call getNumber and showPrimearrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr