## Description

Objectives:

Use if statement, loops, math library, and functions.

Step 1: Set up a separate directory for this lab

First log on and open a terminal window to create a separate directory to work on

this lab. Issue the following commands to create a directory:

a. Type cd 2400/Labs

b. Type mkdir lab3

c. Type cd lab3

Step 2: Area of a triangle:

Write a program that calculates the area of a triangle using the lengths of the sides

(Heron’s formula). The program should read (input) the three sides of the triangle

and check if the triangle is valid first. A triangle is valid if the sum of any two sides is

greater than the third. Your program should run continuously until the user enters

a negative number for any of the sides. (Hint: use a sentinel loop)

Display an error message if the triangle is not valid.

Display the area using two decimal places.

The area of the triangle can be calculated using the following formulas:

� = ����1 + ����2 + ����3

2 ���� = -�(� − ����1)(� − ����2)(� − ����3)

Try the following input values:

• 5, 2, 1 (Invalid)

• 1, 1, 3 (invalid)

• 1, 3, 1 (invalid)

• 5, 5, 5 (Valid, 10.83)

• 3, 4, 5 (Valid, 6.00)

• 9, 10, 10 (Valid, 40.19)

• 0, 0, 0 (quits the program)

Submit your completed program on Blackboard under lab 3.

Grading:

• 30 points (area is calculated correctly)

• 20 Checking for a valid triangle

• 10 points (Program runs continuously)

• 30 points (Error checking and output format)

• 10 points (documentation and style)