• Lenguaje

    PHP

  • Descripción

    Leer las notas obtenidas por 5 alumnos del curso de técnicas de programación y calcule su nota final de acuerdo a la fórmula empleada por su profesor, según los datos de la tabla. Muestre la nota final del alumno y si está aprobado o no, considerando que la nota mínima aprobatoria es 14.
    Código profesor | Fórmula
    A | nf=(n1 + n2)/2
    B | nf=(n1 + n2*2)/3
    C | nf=(n1*2 + n2)/3

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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>Notas de técnicas de programación</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
    </head>
    <body>
<?php

if ($_SERVER['REQUEST_METHOD']=='POST')
{
    $nota_1 = floatval ($_POST['nota_1']);
    $nota_2 = floatval ($_POST['nota_2']);
    $codigo_profesor = intval ($_POST['codigo_profesor']);
    $nota_final=0;
    if($codigo_profesor==1)
        $nota_final=($nota_1+$nota_2)/2;
    if($codigo_profesor==2)
        $nota_final=($nota_1+$nota_2*2)/3;
    if($codigo_profesor==3)
        $nota_final=($nota_1*2+$nota_2)/3;
    if($nota_final<14)
        echo 'Reprobado<br>'
    else
        echo 'Aprobado<br>'
    echo 'Valor de nota final: ' . $nota_final . "<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="nota_1">Ingresa el valor de nota 1:</label>
                        </td>
                        <td>
                            <input name="nota_1" required="required" step="0.000001" type="number" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="nota_2">Ingresa el valor de nota 2:</label>
                        </td>
                        <td>
                            <input name="nota_2" required="required" step="0.000001" type="number" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="codigo_profesor">Selecciona el valor de codigo profesor:</label>
                        </td>
                        <td>
                            <select name="codigo_profesor" required="required">
                                <option value="1">A</option>
                                <option value="2">B</option>
                                <option value="3">C</option>
                            </select>
                        </td>
                    </tr>
                    <tr align="center">
                        <td colspan="2" rowspan="1">
                            <input value="Procesar" type="submit" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </body>
</html>