LAB 2




RESISTENCIAS: VECTORES

#include<iostream>


#include<math.h>
using namespace std;

int i,resistencia [10], MAX, min;

int main ()

    {
    int opcion;
   
               do
               {//INICIO DEL DO - WHILE
   
    cout<<"******************** MENU DE OPCIONES *******************\n";
    cout<<"*********************************************************\n\n";
    cout<<"1)LECTURA DE LAS RESISTENCIAS EN SERIE\n";
    cout<<"2)ESCRITURA DE LAS RESISTENCIAS\n";
    cout<<"3)CALCULO DE LA MAXIMA RESISTENCIA\n";
    cout<<"4)CALCULO DE LA RESISTENCIA MINIMA\n";
    cout<<"5)CALCULO DE LA RESISTENCIA TOTAL\n\n";
    cout<<"DIGITE <0> PARA SALIR\n";
    cout<<"**************\n";
    cout<<"ELIJE UNA OPCION: "; cin>>opcion;
    cout<<"**************\n";
    cout<<endl;
   
   
    switch (opcion)
     {
     
      case 1:
           {
                   cout<<"---------- LECTURA DE LAS RESISTENCIAS EN SERIE ----------\n\n";
                       for (i=1; i<=10; i++)
                           {
                           cout<<"INGRESE LA RESISTENCIA R[ "<<i<<" ] = "; cin>>resistencia[i];             
                           }
                   cout<<endl;
           }
          
           break; //FIN DEL CASO 1
          
       case 2:
           { 
                    cout<<"---------- ESCRITURA DE LAS RESISTENCIAS ----------\n\n";
                        for (i=1; i<=10; i++)
                            {
                            cout<<" LA RESISTENCIA R[ "<<i<<" ] = "<<resistencia[i]<<endl;       
                            }
                    cout<<endl;

             
           }
          
           break; //FIN DEL CASO 2
          
       case 3:
           {
                    cout<<"---------- CALCULO DE LA MAXIMA RESISTENCIA ----------\n\n";
                      int MAX=0;
                      for (i=1; i<=10; i++)
                          {
                          if(resistencia[i]>MAX)
                          MAX = resistencia[i];
                          }
   
                    cout <<" LA RESISTENCIA MAXIMA ES: "<<MAX;
                    cout<<endl;

           }
          
           break; //FIN DEL CASO 3
          
        case 4:
           {
                     cout<<"---------- CALCULO DE LA RESISTENCIA MINIMA ----------\n\n";
                       int min=10000;
                       for (i=1; i<=10; i++)
                           {
                           if(resistencia[i]<min)
                           min = resistencia[i];
                           }
                        
                      cout <<" LA RESISTENCIA MINIMA ES: "<<min;
                      cout<<endl;

           }
          
           break; //FIN DEL CASO 4 
              
         case 5:
           {     
                    cout<<"---------- CALCULO DE LA RESISTENCIA TOTAL ----------\n\n";   
                      int Suma = 0;
                      for (i=1; i<=10; i++)
                       Suma = Suma + resistencia[i];
                    cout<<"--------------------------- \n ";
                    cout<<"LA RESISTENCIA TOTAL ES: "<< Suma << endl;
                    cout << endl;

           }
          
           break; //FIN DEL CASO 5         
        }
                  } while (opcion!=0); //FIN DEL DO - WHILE
   
    system ("pause");
    return 0;
   
    }

No hay comentarios:

Publicar un comentario