Question: In C can be used to interpolate values between every two points. These latter techniques are outside the scope of this assignment. For purposes of
In C




can be used to interpolate values between every two points. These latter techniques are outside the scope of this assignment. For purposes of this assignment, let's initialize our data set to contain the following points. (y,t) represents the position of an object in meters at time t. (Later we may modify this program to read data points from an input file.) Note that the point Table 4.3 Time and position for a moving body. t (seconds) 0 3 10 12 15 18 y (meters) 2 5.2 6 1010.4 13.4 14.8 18 Viewing these data in a graphical format: 16 14 12 4 2 0 2 468 10 12 14 16 18 t (seconds) Figure 4.6 Position versus time for a moving body with data in Table 4.3 You can store the time and distance values in two separate parallel arrays or in an array of structures. Your program should do the following: 1. 2. Initialize time and distance arrays to the above values using initialization lists Ask the user for some number of seconds between 0 and 18 inclusive. a. b. This should be a floating point data type, either float or double. If the user inputs a value outside that range, your program should print an error message and give the user the chance to enter another number. 3. Determine where on the time scale the inputted number resides. For example, if the user inputs the number 11, that resides between the time values of 10 and 12. a. Calculate the interpolated result for y (meters) using linear interpolation and print the result on the screen Give the user the chance to enter another number if desired. 4. 5. and Other Besides the main ) function, your program should, at minimum, contain the following function. Note that the exact specifications for the input parameters were deliberately not provided as part of the exercise.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
