Concept explainers
Kinetic Energy
In physics, an object that is in motion is said to have kinetic energy. The following formula can be used to determine a moving object's kinetic energy:
The variables in the formula are as follows: KE is the kinetic energy, m is the object’s mass in kilograms, and v is the object's velocity, in meters per second.
Design a function named kineticEnergy that accepts an object’s mass (in kilograms) and velocity (in meters per second) as arguments. The function should return the amount of kinetic energy that the object has. Design a
Want to see the full answer?
Check out a sample textbook solutionChapter 6 Solutions
STARTING OUT W/PROGRAM.LOGIC...-TEXT
Additional Engineering Textbook Solutions
Starting Out with Java: From Control Structures through Data Structures (4th Edition) (What's New in Computer Science)
Computer Science: An Overview (12th Edition)
Starting Out with Python (3rd Edition)
Software Engineering (10th Edition)
Starting out with Visual C# (4th Edition)
- (Civil eng.) Write an assignment statement to calculate the linear expansion in a steel beam as a function of temperature increase. The formula for linear expansion, l, is as follows: l=l0(1+(TfT0)) l0isthelengthofthebeamattemperatureT0.isthecoefficientoflinearexpansion.Tfisthefinaltemperatureofthebeam.arrow_forward(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(Civil eng.) Write a C++ program to calculate and display the maximum bending moment, M, of a beam that’s supported on both ends (see Figure 3.8). The formula is M=XW(LX)/L, where X is the distance from the end of the beam that a weight, W, is placed, and L is the beam’s length. You program should produce this display: The maximum bending moment is xxxx.xxxx The xxxx.xxxx denotes placing the calculated value in a field wide enough for four places to the right and left of the decimal point. For your program, assign the values1.2,1.3,and11.2toX,W,andL.arrow_forward
- (Physics) Buoyancy is the upward force a liquid exerts on a submerged object, as shown in Figure 6.9. The buoyancy force is given by this formula: B=pgV Bisthebuoyancyforce( lbforN).isthefluiddensity( slug/f t 3 orkg/ m 3 ).gistheaccelerationcausedbygravity( 32.2ft/se c 2 or9.8m/ s 2 ).Vistheobjectsvolume( f t 3 or m 3 ). a. Using this formula, write a function named buoyantForce(double ro, double vol, int units) that accepts a fluid density, the volume of an object placed in the fluid, and the units to be used(1=U.S.Customaryunits,2=metricunits), and returns the buoyancy force exerted on the object. b. Include the function written for Exercise 6a in a working C++ program, and use your program to complete the following chart:arrow_forward(Civil eng.) Write an assignment statement to determine the maximum bending moment, M, of a beam, given this formula: M=XW(LX)L X is the distance from the end of the beam that a weight, W, is placed. L is the length of the beam.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
- b - Falling Distance When an object is falling because of gravity, the following formula can be used to determine the distance the object falls in a specific time period: d = 1/2 gt2 The variables in the formula are as follows: d is the distance in meters, g is 9.8, and t is the amount of time, in seconds, that the object has been falling. Write a function named fallingDistance that accepts an object’s falling time (in seconds) as an argument. The function should return the distance, in meters, that the object has fallen during that time interval. Write a program that demonstrates the function by calling it in a loop that passes the values 1 through 10 as arguments and displays the return valuearrow_forwardIn physics, an object that is in motion is said to have kinetic energy. The following formula can be used to determine a moving object’s kinetic energy: KE = 1⁄2 mv2 The variables in the formula are as follows: KE is the kinetic energy in joules, m is the object’s mass in kilograms, and v is the object’s velocity in meters per second.Write a function named kineticEnergy that accepts an object’s mass (in kilograms) and velocity (in meters per second) as arguments. The function should return the amount of kinetic energy that the object has. Demonstrate the function by calling it in a program that asks the user to enter values for mass and velocity.arrow_forwardFunction Name: leapYear Parameters: year – an nonnegative integer representing the year Test Cases: >>>leapYear(1996) The year 1996 is a leap year. Enjoy your extra day! >>>leapYear(1901) The year 1901 is not a leap year. Description: Write a function which calculates whether or not a given year is a leap year and has 366 days instead of 365. A general algorithm is as follows: 1. A year will be a leap year if it is divisible by 4 but not by 100. 2. If a year is divisible by 4 and by 100, it is not a leap year unless it is also divisible by 400. Years such as 1996, 1992, 1988 and so on are leap years because they are divisible by 4 but not by 100. For century years, the 400 rule is important. Century years (ex: 1900, 1800, 1700) are exactly divisible by 4 AND exactly divisible by 100. They are not divisible by 400 and are thus not leap years. You fuction should print out "The year XXXX is a leap year. Enjoy your extra day!" if the year XXXX is a leap year. Print "The…arrow_forward
- In physics, an object that is in motion is said to have kinetic energy. The following formula can be used to determine a moving object's kinetic energy: KE = ½ m v2 The variables in the formula are as follows: KE is the kinetic energy, m is the object's mass in kilograms, and v is the object's velocity, in meters per second. Write a function named kineticEnergy that accepts an object's mass (in kilograms) and velocity (in meters per second) as arguments. The function should return the amount of kinetic energy that the object has. Demonstrate the function by calling it in a program that asks the user to enter values for mass and velocity.arrow_forwarder 6 Functions Programming Exercises te 1. Rectangle Area ngle Area The area of a rectangle is calculated according to the following formula: Area = Width X Length Design a function that accepts a rectangle's width and length as arguments and returns the rectangle's area. Use the function in a program that prompts the user to enter the rectangle's width and length, and then displays the rectangle's area.arrow_forwardPlants Growth Cycle Learning Objectives In this lab, you will practice: Defining a function to match the given specifications Calling the function in your program Using if statements (can combine them with dictionaries) Instructions For every plant, there is a growth cycle. The number of days that it takes starting from being a seed and ending in being a fruit is what is called the growth cycle. Write a function that takes a plant's name as an argument and returns its growth cycle (in days). In your program: Input from the user the name of a plant Check if the input is either "strawberry", "cucumber" or "potato", if Yes: 2.1 Call calculate_growth_cycle 2.2. In function calculate_growth_cycle, check over the plant's name: 2.2.1 If strawberry, print "### The life cycle of a strawberry ###" and return 110 2.2.2 If cucumber, print "### The life cycle of a cucumber ###" and return 76 2.2.3 If potato, print "### The life cycle a potato ###" and return 120 2.3 With the growth cycle…arrow_forward
- C++ for Engineers and ScientistsComputer ScienceISBN:9781133187844Author:Bronson, Gary J.Publisher:Course Technology PtrC++ Programming: From Problem Analysis to Program...Computer ScienceISBN:9781337102087Author:D. S. MalikPublisher:Cengage Learning