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++
Additional Engineering Textbook Solutions
C++ How to Program (10th Edition)
Objects First with Java: A Practical Introduction Using BlueJ (6th Edition)
Starting Out with Programming Logic and Design (5th Edition) (What's New in Computer Science)
Starting Out with C++ from Control Structures to Objects (8th Edition)
Programming in C
Database Concepts (8th Edition)
- 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_forwardRe-write the following function so that a given XAND return the value of f(x).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_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_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_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_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_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
- Note: 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_forwardMake 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_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_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology Ptr