Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

#include #include // Symbolic Constant #define G 9.8 // in m/s^2 #define NUM_VALUES 30 // Number of time/velocity values to display // Structure for user

image text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribedimage text in transcribed

#include #include // Symbolic Constant #define G 9.8 // in m/s^2 #define NUM_VALUES 30 // Number of time/velocity values to display // Structure for user input typedef struct { double weight; // in kg double drag; // in kg/s double finalTime; // in seconds } USER_INPUT; // function protyptes double calculateVelocity(USER_INPUT, double); /*--------------------------------------------------------------------- Fonction: main Description: Gets from user mass, drag coeff., and final time stored in a structure variable, then computes time/velocity values stored in a 2D array and then displays input values and computed values in a table. ------------------------------------------------------------------------*/ int main(void) { // Variable declations USER_INPUT input; // A structure variable user input // Arrays double times[NUM_VALUES]; double velocities[NUM_VALUES]; double t; // to vary time value double inc; // for incrementing time int ix; // for indexing arrays.

// Get input from user // Not necessary to verify the values input.

// Calculate the velocities for storing into arrays // Vary the time between 0.0 and finalTime (member of input) // and calculate the speed at each of these times. Fill // the times and velocities arrays with these values.

// Display results // Display the values from the input structure variable // and the array values in a table on the console return(0); } /*----------------------------------------------------------------------- Function: calculateVelocity Parameters: input - input values from the user t - time in secondes Return: Velocity of the parachutist at time t. Description: Computes the velocity of the parachutists with given drag and weight at time t. ------------------------------------------------------------------------*/ double calculateVelocity(USER_INPUT input, double t) { // Variable declations // COmplete this function. }

The objective today is to revise the program to use a structure to collect input data rather than using individual variables and to use arrays for computing and displaying how the velocity of the parachutist changes between time 0.0 and a final time given by the user. Recall that the relationship between velocity, v (m/s), parachutist weight, m (kg), and drag coefficient, c (kg/s), is gm -(clm)t The equation computes the velocity of the parachutist at a given time using the weight of the parachutist and a drag coefficient. At t-0, the velocity of the parachutist is zero. Starting with the project template given in the file parachutist zip, develop a program that gets from the user the weight, drag coefficient and a final time. The program then calculates 30 pairs of time/velocity values between 0.0 and the given final time. The program will output all input values and the calculated velocity and then in a table the time/velocity values The following table provides test cases that can be used for testing the software (this table was generated using The velocity was computed using the above equation Microsoft Excel with a masse of 68.1 kg, a drag coefficient of 12.5 kg/s and a final time of 40.0 s. Time t (s Vclocity(m/s) 0 1.379311.94182184 2.758621.21261839 4.1379 28.40981742 5.517233.99722015 38.33488944 8.275941.70235297 44.3166165 1.0345 46.34614813 12.413847.92173477 13.79349.14491021 50.0944982 50.831692 17.931051.40399779 19.3103 51.84829604 20.689752.19321818 22.0690 52.46099164 23.4483 52.66887225 .83025624 52.9555435 27.586253.05280778 0.0000 6.8966 9.6552 15.1724 16.5517 24.827652 26.2069 28.965553 30.344853.18693704 31.724153.23244557 33.103453.26777521 34.482853.29520268 35.862153.31649545 37.241453.33302566 38.620753.34585857 40.0000 53.35582115 .12831698 Use the following guidelines to create your program 1) Symbolic Constants a. G-set to the value of gravitational constant, 9.8 m/s b. NUM_VALUES -to set the number of values to display in the table, 30. 2) C Structures: a. Define a structure type "USER INPUT" which has three members, weight, drag, and finalTime (all of type double). 3) Function main a. Local Variables input: a structure variable of type USERINPUT that contains the three input values obtained from the user. . - ith NUM_VALUES elements to st iii. velocities: An array with NUM VALUES elements to store the co mputed velocities to display b. Logic/Strategies iv. In a first step, prompt the user for the three values weight, drag coefficient and time. These values are stored in the structure variable input (you will need to pass the value of this structure variable to the function calculateVelocity). In a second step, vary the time between 0 and finalTime (member of the structure variable input) and calculate the velocity at each time value. Store the time value in the array times and the velocity values in the array velocities (note that the value of the velocity at an index of v. velocities is calculated at the value of time at the index of times). Use the function calculateVelocity to compute the velocity at a given time. Pass the value of the structure variable input to this function. vi. In a third step, display on the console, output that gives the characteristics of the parachutist followed by a table that shows how the velocity of the parachutist changes with time. Format (using printf) the output as shown below. Please enter the values for weight Please enter the values for drag coefficient 12.5 ease enter the values for final time: 40 The speeds of the par t with weight 68.10 kg nd drag coefficient Time Velocity m/s 0.00 0.00 28 49 69 07 6 rocess returned (x) execution time 14.049s Press any key to continue. 4) Function: calculateVelocity Determine appropriate parameters (a structure variable and time variable) and local variables for the function a. velocity from the value equation c. The function returns the calculated velocity

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Databases In Networked Information Systems 6th International Workshop Dnis 2010 Aizu Wakamatsu Japan March 2010 Proceedings Lncs 5999

Authors: Shinji Kikuchi ,Shelly Sachdeva ,Subhash Bhalla

2010th Edition

3642120377, 978-3642120374

More Books

Students also viewed these Databases questions

Question

What is a partial correlation coefficient?

Answered: 1 week ago

Question

Describe the types of power that effective leaders employ

Answered: 1 week ago

Question

Describe how leadership styles should be adapted to the situation

Answered: 1 week ago