Starting from:
$30

$24

0CS Program 2 Solution

Administrative:

    1. Put your information (name, class, etc) in a header comment block.

    2. Please comment appropriately. We are not looking for “production quality” comments but the grader should be able to follow your code. This is particularly important if you code does not work properly.

Description of the Assignment:

For this assignment, you will be given a file that contains multiple lines of text, each line formatted as follows:

    1. The first non-blank character will be ‘i’ or ‘p’. ‘i’ implies that the data that follows describes the implicit equation of a line. ‘p’ implies that the data that follows describes the parametric equation of a line.

        a. If implicit, the next three real-valued text fields are coefficients a, b, and c, separated by one or more spaces.
        b. If parametric, the next four real-valued text fields are p1, p2, v1 and v2.

    2. After the description of the line, the next six real-valued text fields describe points for evaluation.

Examples of the input file:

The following describes the implicit form of a line 2.5a + 3.2b -9.2 =0. The three points that follow are (1.0, 2.0), (1.5, 3.0) and (-0.5, 3.2):

i    2.5    3.2  -9.2  1.3  1.0  2.0  1.5  3.0  -0.5  3.2



This following describes the parametric form of the line ( ) = [23..52] + [−19.3.2], with the same points as above, (1.0, 2.0), (1.5, 3.0) and (-0.5, 3.2):

p  1.0  1.0 1.5  3.2 1.0  2.0 1.5 3.0 -0.5  3.2


For each line of text in the input file, your program:
    1. Displays the equation of the line, labelled as “implicit” or “parametric.”

    2. Display the other form of the line. For example, if the input describes the implicit for, your program would print the parametric for of the line. If the input was parametric, print the implicit form of the line.

    3. Print the point-normal form of the line.

    4. For each of the three points in the input, the program should print the point and the distance of the point to the line. If the point is on the line, say so.




Example (Updated on 30 Sep 2021)
Input: i  3.0  4.0  -5.0    -5.0    5.0    4.00  0.00    -1.5  0.5

might have output that looks something like this:

Implicit form: 3.0a + 4.0b + -5 = 0
Parameter form: l(t) = [0.0, 1.25] +  t[4.0, -3.0]

Point-normal form: 0.6x1  + 0.8x + -1 = 0
Distance from point (-5.0, 5.0] to the line is 0.0. The point is on the line.

Distance from point [4.0, 0.0] to the line is 2.4.

Distance from point [-1.5, 0.5] to the line is -1.5.




Deliverables:

    1. Provide a PDF or text version of your source file(s).

    2. Create a video of your program running correctly. You can use a screen capture program or just record with (for example) a smart phone. This video should be uploaded to Canvas.

    3. On the Canvas submission, note anything that didn’t work properly.

Rubric
    1. Output your name and assignment number.

    2. Show all the code, explaining STEP BY STEP what it does and how you do it. For this assignment this part will count more since it’s most of the project.

    3. Run the code and show the output. If it doesn’t run or output isn’t correct, explain why you think it isn’t working.

More products