Question: Problem B. Getting familiar with Dynamic Allocation (20 points) Force is defined as the product of an item's mass and its acceleration. Mass is a

 Problem B. Getting familiar with Dynamic Allocation (20 points) Force is

Problem B. Getting familiar with Dynamic Allocation (20 points) Force is defined as the product of an item's mass and its acceleration. Mass is a scalar value, whereas acceleration is generally expressed as a vector quantity with three components (the component of acceleration along the x axis, the component of acceleration along the y axis, and the component of acceleration along the z axis). The product of the scalar mass and the acceleration yields force as a vector quantity Write a PURE function named force that will accept the following arguments (i)Three values (type double) that hold the acceleration in the x, y, and z directions respectively and, A mass (type double) (ii) The function force should return a dynamically allocated array representing the force. Location 0 in the array should hold the value of force in the x direction, location 1 in the array should hold the value of force in the y direction, and location 2 in the array should hold the value of force in the z direction Note that the force is determined by multiplying the scalar mass by each component of acceleration that is passed to the force function. Test your force function by constructing a short main program that will ask the user to input values for the acceleration and mass from the console, and calculate and then display the force calculated by the force function. The program should also display the magnitude of the force which is: force in x directon. force in y direction + force in z direction An example of a run of your program should be similar to the following (note that user input is in bold font) Welcome to the force calculation program Please enter the mass of the object (in kilograms): 5.0 Please enter the acceleration of the object along each axis (x,y, z) in meters/second': 7.0 3.0 5.0 The force of the object is: 35.00 newtons in the x direction 15.00 newtons in the y direction 25.00 newtons in the z direction The magnitude of the force is 45.55 newtons Would you like to continue (Enter 'y' or 'n'): n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!