-
Lenguaje
PHP
-
Descripción
Algoritmo que permite ingresar los dos lados de un cuadrilátero, y muestra el texto "Es un cuadrado" si ambos lados forman un cuadrado o muestra el texto "Es un rectángulo" si la figura que se forma con dichos lados es un rectángulo, además mostrar el área y el perímetro de dicha figura.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<title>Cuadrado o rectángulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<?php
<html>
<head>
<title>Cuadrado o rectángulo</title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
if ($_SERVER['REQUEST_METHOD']=='POST')
{
$lado_a = floatval ($_POST['lado_a']);
$lado_b = floatval ($_POST['lado_b']);
$area=$lado_a*$lado_b;
$perimetro=($lado_a+$lado_b)*2;
if($lado_a==$lado_b)
echo 'Es un cuadrado<br>'
else
echo 'Es un rectángulo<br>'
echo 'Valor de area: ' . $area . "<br/>\n";
echo 'Valor de perimetro: ' . $perimetro . "<br/>\n";
}
<form method="post">
<table style="text-align: left; margin-left: auto; margin-right: auto;" border="1" cellpadding="1" cellspacing="1">
<tbody>
<tr>
<td>
<label for="lado_a">Ingresa el valor de lado a:</label>
</td>
<td>
<input name="lado_a" required="required" step="0.000001" type="number" />
</td>
</tr>
<tr>
<td>
<label for="lado_b">Ingresa el valor de lado b:</label>
</td>
<td>
<input name="lado_b" required="required" step="0.000001" type="number" />
</td>
</tr>
<tr align="center">
<td colspan="2" rowspan="1">
<input value="Procesar" type="submit" />
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>
<table style="text-align: left; margin-left: auto; margin-right: auto;" border="1" cellpadding="1" cellspacing="1">
<tbody>
<tr>
<td>
<label for="lado_a">Ingresa el valor de lado a:</label>
</td>
<td>
<input name="lado_a" required="required" step="0.000001" type="number" />
</td>
</tr>
<tr>
<td>
<label for="lado_b">Ingresa el valor de lado b:</label>
</td>
<td>
<input name="lado_b" required="required" step="0.000001" type="number" />
</td>
</tr>
<tr align="center">
<td colspan="2" rowspan="1">
<input value="Procesar" type="submit" />
</td>
</tr>
</tbody>
</table>
</form>
</body>
</html>