CS 115 Lab 3 Practice with Math Library Function

80 Points

Due Date: Monday February 15 by the end of the lab session

Submit the program you write with the Canvas link on the assignment.

Educational goals of this lab - verify that every student can

Description of the problem:

Points on the Cartesian plane are specified by x, y pairs, like (x1, y1) and (x2, y2). The distance between two points is given by the formula .

The points can describe different shapes. Given 3 points, you can describe a triangle. Yes, there are exceptions which we won't worry about now.

The sum of the length of the three sides of the triangle is called the perimeter.
Above is a formula for the area of a triangle (ANY triangle). It is called "Heron's formula" (also "Hero's formula"). s is defined as the perimeter divided by 2 (called a semi-perimeter). a, b and c are the lengths of the sides of the triangle.

Your job is to allow the user to enter the coordinates of 3 points and then calculate the perimeter and area of the triangle given by the 3 points. You can assume the coordinates are integers.

(24 points) Team Problem #1: Test Cases (work these out FIRST!, before class if possible)

Create a multi-line comment at the bottom of your program file which contains the answers that go in the blanks below. It should be the expected output from the program described below, the payment, given the inputs in the case. Use a calculator as needed. Here is a online calculator that you can use. You get 12 points for calculating them, 12 points when your program runs and gives the correct answers. You do NOT want to copy the output of the program here and paste it in! You are doing these BEFORE the program is written!
DescriptionInputs
x1, y1, x2, y2, x3, y3
Expected Outputs
Perimeter
Area
Normal cases
Normal case with
positive coordinates
1,1,3,4,5,17 ____A.____
Normal case with
negative ints for some inputs
-4,3,2,1,0,4 ____B.____
Triangle with large sides 100000,5, 2000,4,3,9 ____C.____
Two sides are length 1 1,1, 2,1,1,2 ____D.____
All coordinates are the same 1,1,1,1,1,1 ____E.____
All coordinates are on the same straight line 1,1,2,2,3,3 ____F.____

Remember these answers, A-F, are in a multi-line comment at the bottom of the team lab3.py file.

(15 points) Team Problem #2: Design

  • In your prolog at the TOP of your lab3.py file, include the names of all team members who are PRESENT at the lab (emails not needed). Also include the purpose, pre- and post-conditions for the program. Remember to give the types of each input and output value.

    Paste this design into your lab3.py file and complete the last 2 steps.

        #1. Print title
        #2. Get 6 inputs from user (x,y,x,y,x,y)
        #3. Calculate the distances between each pair of points (lengths of sides)
    
        COMPLETE THIS 
    

    (53 points) Team Problem #3: Implementation

    If you do not attend lab, you will NOT get the points for the Team Problem, even if your team does submit a solution!

    Make sure you save your programs somewhere as a backup to the copy on Canvas! Teams forget to submit sometimes!