top of page

TERCERA PRÁCTICA CALIFICADA


17) Programación de Algoritmos (PAL404) - PÁG. 14 SERIE SENO(X)
https
://www.udb.edu.sv/udb_files/recursos_guias/informatica-tecnologico/programacion-de-algoritmos/2020/i/guia-10.pdf
- PÁG.10 (EJEMPLO 4)

SOLIS VILCARIMA ROBERTO CARLOS

#include <iostream>
#include <iomanip>
#include <math.h>
using namespace std;

int angulo, Opcion, c, SUMA;
int FACT,CC,n,a,b, A;
float M,N,RAD, B, PI=3.141592; 

int SUMAR(int x, int y);
float SERIE_SENO(int x);

void descuentos(float sb, int nivel, float &isss, float &renta, float &seguro);
float calculobono(float sb, int nivel);
float verempleado(float sb, int nivel, float isss, float renta, float seguro, float bono);

int main() {
    do {
        cout << "   M E N U  de FUNCIONES  \n";
        cout << "------------   \n";
        cout << "1.- SUMA  \n";
        cout << "2.- SERIE SENO  \n";
        cout << "3.- PLANTEADO \n";
        cout << "4.- SU LIBRO \n";
        cout << "INGRESE UNA OPCION <> 0: "; 
        cin >> Opcion;
        switch (Opcion) {
            case 1: {
                cout << "1.- SUMA DE DOS NUMEROS \n";
                cout << "Ingrese el numero 1: "; 
                cin >> a;   
                cout << "Ingrese el numero 2: "; 
                cin >> b;
                A = SUMAR(a, b);
                cout << "La suma es: " << A << endl;
                break;
            }
            case 2: {
                cout << "2.- SERIE SENO  \n";
                cout << "------------------  \n";        
                cout << "Ingrese el valor del angulo: "; 
                cin >> angulo;
                B = SERIE_SENO(angulo);
                cout << "La suma de la serie seno es: " << B << endl;
                break;
            }
            case 3: {
                float sueldob, disss, drenta, dseguro, sbono, montoisss, planilla;
                int niv, te = 0;
                cout << "Aplicacion Contable de LA CONSTANCIA SA\n";
                cout << "Ingrese el sueldo base de cada uno de sus 4 empleados.\n";
                montoisss = 0.0;
                planilla = 0.0;
                for(te = 1; te <= 4; te++) {
                    cout << "\nEmpleado # " << te << endl;
                    cout << "\nSueldo base ?? $"; 
                    cin >> sueldob;
                    cout << "\nNivel (entre 0 a 4) ??"; 
                    cin >> niv;
                    descuentos(sueldob, niv, disss, drenta, dseguro);
                    sbono = calculobono(sueldob, niv);
                    montoisss += disss;
                    planilla += verempleado(sueldob, niv, disss, drenta, dseguro, sbono);
                }
                cout << "\nMonto retenido en concepto de ISSS: $" << montoisss;
                cout << "\nPlanilla a pagar: $" << planilla;
                break;
            }
        }
    } while (Opcion != 0);
    return 0;
}

int SUMAR(int x, int y) {
    SUMA = x + y;
    return SUMA;
}

float SERIE_SENO(int x) {
    RAD = (2 * PI * x) / 360;
    CC = 0;
    SUMA = RAD;
    FACT = 1;
    cout << "Cuanto terminos sumanos: "; 
    cin >> n;
    for(c = 1; c <= n; c += 2) {
        M = pow(RAD, c);
        N = FACT * c;
        CC += 1;
        if (CC / 2 != 0)
            SUMA = SUMA + M / N;
        else
            SUMA = SUMA - M / N;
    }
    return SUMA;
}

void descuentos(float sb, int nivel, float &isss, float &renta, float &seguro) {
    isss = 0.031 * sb;
    renta = 0.093 * sb;
    seguro = 0.0;
    switch(nivel) {
        case 2:
        case 3:
            seguro = 0.114 * sb;
            break;
    }
}

float calculobono(float sb, int nivel) {
    switch(nivel) {
        case 0: 
            return 7;
        case 1:
            return 0.064 * sb;
        case 2:
            return 0.1394 * sb;
        case 3:
            return 0.2104 * sb;
    }
    return 0;
}

float verempleado(float sb, int nivel, float isss, float renta, float seguro, float bono) {
    float sf;
    sf = sb - (isss + renta + seguro) + bono;
    cout << "\nSueldo Base $" << setw(8) << sb;
    cout << "\nDescuento de: ISSS $" << setw(5) << isss << "\tRenta $" << setw(5) << renta << "\tSeguro $" << setw(5) << seguro << endl;
    cout << "Bono $" << setw(5) << bono << endl;
    cout << "Sueldoliquido $" << setw(8) << sf << endl;
    return sf;
}

image.png
image.png
bottom of page