top of page

SEMANA 11

Ejercicio en clase y Práctica: 

image.png
image.png
imagen_2024-02-17_164700658.png
image.png

#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

void TABLA();
void LINEAS();
void corriente();
void imperancia();
void resonanciaFrecuencial(); 

int main() {
    int opcion;
    do {
        cout << "\n======== MENU DE FUNCIONES ========" << endl;
        cout << "  [1] TABLA DE MULTIPLICAR" << endl;
        cout << "  [2] DIBUJO DE LINEAS" << endl;
        cout << "  [3] CALCULAR CORRIENTE" << endl;
        cout << "  [4] IMPERANCIA" << endl;
        cout << "  [5] RESONANCIA FRECUENCIAL" << endl; 
        cout << "  [6] SALIR" << endl; 
        cout << "====================================" << endl;
        cout << "INGRESE UNA OPCION: ";
        cin >> opcion;

        switch (opcion) {
            case 1: {
                cout << "\n----- TABLA DE MULTIPLICAR -----" << endl;
                TABLA();
                break;
            }
            case 2: {
                cout << "\n----- DIBUJO DE LINEAS -----" << endl;
                LINEAS();
                break;
            }
            case 3: { 
                cout << "\n----- CALCULAR CORRIENTE -----" << endl;
                corriente(); 
                break;
            }
            case 4: { 
                cout << "\n----- IMPERANCIA -----" << endl;
                imperancia(); 
                break;
            }
            case 5: { 
                cout << "\n----- RESONANCIA FRECUENCIAL -----" << endl;
                resonanciaFrecuencial(); 
                break;
            }
            case 6: { 
                cout << "Saliendo del programa..." << endl;
                break;
            }
            default: {
                cout << "Opcion invalida. Por favor, intente de nuevo." << endl;
            }
        }
    } while (opcion != 6); 

    return 0;
}

void TABLA() {
    for(int i = 1; i <= 12; i++) {
        cout << "TABLA DEL " << i << ":" << endl;
        cout << "-------------------------" << endl;
        for(int j = 1; j <= 12; j++)
            cout << setw(2) << i << " * " << setw(2) << j << " = " << setw(3) << i*j << endl;
        cout << "-------------------------" << endl << endl;
    }
}

void LINEAS() {
    cout << endl;
    cout << "---------------------------------------------" << endl;
    cout << "---------------------------------------------" << endl << endl;
}

void corriente() {
    cout << "Para calcular la corriente, por favor ingrese los siguientes valores:" << endl;
    double R, L, C, w;

    cout << "Resistencia (R): ";
    cin >> R;
    cout << "Inductancia (L): ";
    cin >> L;
    cout << "Capacitancia (C): ";
    cin >> C;
    cout << "Frecuencia angular (w): ";
    cin >> w;

    const double phi = 3.14159265; // Definimos phi aquí
    cout << "\n--- Resultados ---" << endl;
    for(double Vo = 10; Vo <= 220; Vo += 10) {
        double Io = Vo / sqrt(pow(R, 2) + pow((w * L - 1 / (w * C)), 2));
        cout << "Para Vo = " << Vo << ", Io = " << Io << endl;
    }
}

void imperancia() {
    cout << "Para calcular la impedancia, por favor ingrese los siguientes valores:" << endl;
    double R, L, C, w;

    cout << "Resistencia (R): ";
    cin >> R;
    cout << "Inductancia (L): ";
    cin >> L;
    cout << "Capacitancia (C): ";
    cin >> C;
    cout << "Frecuencia angular (w): ";
    cin >> w;

    const double phi = 3.14159265; // Definimos phi aquí
    cout << "\n--- Resultados ---" << endl;
    for (double L_value = 10; L_value <= 20; L_value++) {
        for (double C_value = 5; C_value <= 10; C_value++) {
            double Xl = w * L_value;
            double Xc = 1 / (w * C_value);
            double Z = sqrt(pow(R, 2) + pow((Xl - Xc), 2));
            cout << "Para L = " << L_value << ", C = " << C_value << ", Z = " << Z << endl;
        }
    }
}

void resonanciaFrecuencial() {
    cout << "Para calcular la resonancia frecuencial, por favor ingrese los siguientes valores:" << endl;
    double L, C;

    cout << "Inductancia (L): ";
    cin >> L;
    cout << "Capacitancia (C): ";
    cin >> C;

    const double phi = 3.14159265; 

    cout << "\n--- Resultados ---" << endl;
    for (double L_value = 1; L_value <= 5; L_value++) {
        for (double C_value = 10; C_value <= 100; C_value += 20) {
            double fo = 1 / (2 * phi * sqrt(L_value * C_value));
            cout << "Para L = " << L_value << ", C = " << C_value << ", fo = " << fo << endl;
        }
    }
}

bottom of page