• Lenguaje

    JavaScript

  • Descripción

    Pida el nombre del producto, cantidad, precio y alícuota del IVA. Calcular monto base, monto del IVA, monto total. Si el monto de la factura es de 10000 otorgar un descuento de 13%, si es mayor a 30000 otorgar un 17.5% de descuentos. Considere que el descuento debe ser sobre el monto base.

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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "https://www.w3.org/TR/html4/loose.dtd">
<html>
    <head>
        <title>Monto, descuento e IVA de una factura</title>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8">
        <script>
 
function algoritmo()
{
    let IVA, alicuota_del_IVA, cantidad, descuento, monto_base;
    let monto_total, precio;
    let nombre_del_producto = document.formulario1.nombre_del_producto1.value;
    alicuota_del_IVA = parseFloat (document.formulario1.alicuota_del_IVA.value);
    cantidad = parseFloat (document.formulario1.cantidad.value);
    precio = parseFloat (document.formulario1.precio.value);
    monto_base=precio*cantidad;
    descuento=0;
    if(monto_base==10000)
        descuento=monto_base*0.13;
    if(monto_base>30000)
        descuento=monto_base*0.175;
    IVA=(monto_base-descuento)*alicuota_del_IVA/100;
    monto_total=monto_base-descuento+IVA;
    document.formulario1.nombre_del_producto2.value = nombre_del_producto;
    document.formulario1.IVA.value = IVA;
    document.formulario1.descuento.value = descuento;
    document.formulario1.monto_base.value = monto_base;
    document.formulario1.monto_total.value = monto_total;
}
 
        </script>
    </head>
    <body>
        <form name="formulario1">
            <table style="text-align: left; margin-left: auto; margin-right: auto;">
                <tbody>
                    <tr>
                        <td>
                            <label for="nombre_del_producto1">Ingresa el nombre del producto:</label>
                        </td>
                        <td>
                            <input name="nombre_del_producto1" required="required" type="text" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="alicuota_del_IVA">Ingresa el valor de alicuota del IVA:</label>
                        </td>
                        <td>
                            <input name="alicuota_del_IVA" required="required" step="0.000001" type="number" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="cantidad">Ingresa el valor de cantidad:</label>
                        </td>
                        <td>
                            <input name="cantidad" required="required" step="0.000001" type="number" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="precio">Ingresa el valor de precio:</label>
                        </td>
                        <td>
                            <input name="precio" required="required" step="0.000001" type="number" />
                        </td>
                    </tr>
                    <tr align="center">
                        <td colspan="2" rowspan="1">
                            <input value="Procesar" type="button" onclick="algoritmo();" />
                            <input type="reset" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="nombre_del_producto2">Nombre del producto:</label>
                        </td>
                        <td>
                            <input name="nombre_del_producto2" type="text" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="IVA">Valor de IVA:</label>
                        </td>
                        <td>
                            <input name="IVA" step="0.000001" type="number" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="descuento">Valor de descuento:</label>
                        </td>
                        <td>
                            <input name="descuento" step="0.000001" type="number" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="monto_base">Valor de monto base:</label>
                        </td>
                        <td>
                            <input name="monto_base" step="0.000001" type="number" />
                        </td>
                    </tr>
                    <tr>
                        <td>
                            <label for="monto_total">Valor de monto total:</label>
                        </td>
                        <td>
                            <input name="monto_total" step="0.000001" type="number" />
                        </td>
                    </tr>
                </tbody>
            </table>
        </form>
    </body>
</html>