• Language

    PSeInt (Pseudocode)

  • Description

    Write a program that prompts the user to enter the tree points (x1, y1), (x2, y2), and (x3, y3) of a triangle and displays its area.
    The formula for computing the area of a triangle is:
    s = (side1 + side2 + side3) / 2
    area = sqrt(s * (s - side1) * (s - side2) * (s - side3))

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
Proceso AreaOfATriangle
    Escribir Sin Saltar "Enter the value of x1:";
    Leer x1;
    Escribir Sin Saltar "Enter the value of x2:";
    Leer x2;
    Escribir Sin Saltar "Enter the value of x3:";
    Leer x3;
    Escribir Sin Saltar "Enter the value of y1:";
    Leer y1;
    Escribir Sin Saltar "Enter the value of y2:";
    Leer y2;
    Escribir Sin Saltar "Enter the value of y3:";
    Leer y3;
    side1 <- RC((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));
    side2 <- RC((x2-x3)*(x2-x3)+(y2-y3)*(y2-y3));
    side3 <- RC((x3-x1)*(x3-x1)+(y3-y1)*(y3-y1));
    s <- (side1+side2+side3)/2;
    area <- RC(s*(s-side1)*(s-side2)*(s-side3));
    Escribir "Value of area: ", area;
    Escribir "Value of s: ", s;
    Escribir "Value of side1: ", side1;
    Escribir "Value of side2: ", side2;
    Escribir "Value of side3: ", side3;
FinProceso