2. (55 pts) Call this project MathematicalModels. Note this problem is similar to Hanly & Koffman's project 6.4. The table below summarizes three commonly used mathematical models of nonvertical straight lines.

Mode

Equation

Given

Two-point form

m = (y2 - y1) / (x2 - x1)

(x1, y1), (x2, y2)

Point-slope form

y - y1 = m(x - x1)

m, (x1, y1)

Slope-intercept form

y = mx + b

m, b

Design and implement a program that permits the user to convert either two-point form or point-slope form into slope-intercept form. Your program should interact with the user as follows (use input is shown in bold):

Select the form that you would like to convert to slope-intercept form:

1) Two-point form (you know two points on the line)

2) Point-slope form (you know the line's slope and one point)

3) Exit

==> 2 (this is where the user enters a value)

Enter the slope=> 4.2

Enter the x-y coordinates of the point separated by a space=> 1 1

Point-slope form: y - 1.00 = 4.20(x - 1.00)

Slope-intercept form: y = 4.20x - 3.20

Select the form that you would like to convert to slope-intercept form:

1) Two-point form (you know two points on the line)

2) Point-slope form (you know the line's slope and one point)

3) Exit

==> 1

Enter the x-y coordinates of the first point separated by a space=> 4 3

Enter the x-y coordinates of the second point separated by a space=> -2 1

Two-point form:

(1.00 - 3.00)

m = --------------

(-2.00 - 4.00)

Slope-intercept form: y = 0.33x + 1.66

Select the form that you would like to convert to slope-intercept form:

1) Two-point form (you know two points on the line)

2) Point-slope form (you know the line's slope and one point)

3) Exit

==> 3

You are once again given the freedom to determine the appropriate functions required to solve this problem. Use a structure chart to determine how to perform a reasonable top-down design. Note that you must accepts pointers as parameters in at least two of the functions that you implement. I have provided a possible top-down design below (you may ignore these functions and write your own):

get_problem - Displays the user menu, then inputs and returns as the function value the problem number selected.

get2_pt - Prompts the user for the x-y coordinates of both points, inputs the four coordinates, and returns them to the calling function through output parameters (i.e. pointers).

get_pt_slope - Prompts the user for the slope and x-y coordinates of the point, inputs the three values and returns them to the calling function through output parameters.

slope_intercept_from2_pt - Takes four input parameters, the x-y coordinates of two points, and returns through output parameters the slope (m) and the y-intercept (b).

intercept_from_pt_slope - Takes three input parameters, the x-y coordinates of one point and the slope, and returns as the function value the y-intercept.

Other possible functions include: display2_pt ( ), display_pt_slope ( ), and display_slope_intecept ( )

- 5 years ago

**A+ Work**

Purchase the answer to view it

- mathematicalmodels.zip