Sale!

CSCI 2500 Assignment 1 Linear Interpolation solved

$25.00 $21.25

Category:

Description

5/5 - (2 votes)

Frequently when doing experiments we have “holes” in our data. For example, when measuring population
growth in cities or temperature change during an experiment we typically do not have continuous data but
rather samples taken at discrete points in time. Linear interpolation is one way to find these points.
Your task is to fill in the functions to complete the program skeleton given in the template file. This is a
relatively short program to ensure everyone is up to speed on C programming topics. Your program should
accept non-negative X values and arbitrary Y values. It should exit immediately upon non-increasing X
values.
Below are some sample output. Note that your program should match these samples exactly.
bash-3.2$ ./a.out
How many data points would you like to enter? (2 or more): 3
Please enter non-negative X values.
Please enter X[0]: 1
Please enter Y[0]: 1
Please enter X[1]: 2
Please enter Y[1]: 2
Please enter X[2]: 3
Please enter Y[2]: 3
Point[0] is ( 1.000, 1.000)
Point[1] is ( 2.000, 2.000)
Point[2] is ( 3.000, 3.000)
Please enter an X coordinate (-1 to exit): 1.5
1.500 maps to ( 1.500, 1.500)
Please enter an X coordinate (-1 to exit): 2.5
2.500 maps to ( 2.500, 2.500)
Please enter an X coordinate (-1 to exit): 3.5
3.500 cannot be interpolated
Please enter an X coordinate (-1 to exit): -1
bash-3.2$
bash-3.2$ ./a.out
How many data points would you like to enter? (2 or more): 6
Please enter non-negative X values.
Please enter X[0]: 0.5
Please enter Y[0]: 1
Please enter X[1]: 0.8
CSCI 2500
Please enter Y[1]: 14
Please enter X[2]: 1.3
Please enter Y[2]: -2.75
Please enter X[3]: 2.5
Please enter Y[3]: -8.35
Please enter X[4]: 3.5
Please enter Y[4]: 0
Please enter X[5]: 4.3
Please enter Y[5]: 4
Point[0] is ( 0.500, 1.000)
Point[1] is ( 0.800, 14.000)
Point[2] is ( 1.300, -2.750)
Point[3] is ( 2.500, -8.350)
Point[4] is ( 3.500, 0.000)
Point[5] is ( 4.300, 4.000)
Please enter an X coordinate (-1 to exit): 1.4
1.400 maps to ( 1.400, -3.217)
Please enter an X coordinate (-1 to exit): 2.6
2.600 maps to ( 2.600, -7.515)
Please enter an X coordinate (-1 to exit): 2.5
2.500 maps to ( 2.500, -8.350)
Please enter an X coordinate (-1 to exit): 3.4
3.400 maps to ( 3.400, -0.835)
Please enter an X coordinate (-1 to exit): 4.0
4.000 maps to ( 4.000, 2.500)
Please enter an X coordinate (-1 to exit): -1
bash-3.2$
bash-3.2$ ./a.out
How many data points would you like to enter? (2 or more): 3
Please enter non-negative X values.
Please enter X[0]: 1.5
Please enter Y[0]: 3.4
Please enter X[1]: 0.8
Please enter points in order of ascending X values.
bash-3.2$
CSCI 2500