viernes, 7 de junio de 2013

Segundo trabajo de LP


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

// VARIABLES PUBLICAS
int opcion,n,i,d,v,b;
double t;
int main ()
{
  // TOMA D DECISION MUILTIPLE
  // INICIO DEL BUBLE DO WHILE
  do
  {
     cout<<"---------------------";
     cout<<"MENU PRINCIPAL \n \n";
     cout<<"1) CALCULO DEL CAMPO ELECTRICO \n";
     cout<<"2) CALCULO DE LA ENERGIA POTENCIAL GRAVITATORIA \n";
     cout<<"3) CALCULO DE LA FUERZA DE INTENSIDAD \n";  
     cout<<" INGRESE UNA OPCION /<0> PARA SALIR \n\n";     cin>>opcion;
 
 
     switch (opcion)
      {
case 1:
           {

           double r;
           int final;
           cout<<"-----------------------------------------\n";
           cout << "CALCULO DEL CAMPO ELECTRICO \n\n" << ", ";
           cout << "INGRESE LA CARGA GENERADORA: "; cin>>final;
           cout << "INGRESE LA DISTANCIA: "; cin>>d;
           for (n=1; n<=final; n++)
             {
               //PROCESO DE CALCULO
               r = (9000*1000000*n)/d*d;    
               cout << r << ", ";
              }
             cout <<"\n"<< r << ", \n ";;
             cout << "FIN!\n";
            }
           break;
         
case 2:
           {    
            int final;  
            cout<<"group of statements 2 \n";
           // CALCULO DE LOS NUMEROS IMPARES
           cout << "\n\n";
           cout << "-----------------------------------------------------------------\n";
           cout << "USO DEL COMANDO WHILE CALCULO DE LA ENERGIA POTENCIAL GRAVITATORIA \n\n";
           cout << "Ingrese LA MASA > ";cin >> final;
           cout << "INGRESE LA ALTURA: "; cin>>b;
            i=1;
            while (i<=final)
              {
               cout << i*b*10 << ", \n ";
               ++i;
              }
            cout << "FIN\n";
           }
            break;
case 3:
           {
            int final;  
            double r;
           // CALCULO DE LOS PUNTOS F(X) DE UNA PARABOLA
           cout << "\n\n";
           cout << "-----------------------------------------------------------------\n";
           cout << "USO DEL COMANDO WHILE --- CALCULO DE LA FUERZA DE INTENSIDAD \n\n";
           cout << "Ingrese la primera carga = ";cin >> b;
           cout << "INGRESE la segunda carga: "; cin>>v;
           cout << "INGRESE la distancia: "; cin>> final;
            i=1;
            while (i<=final)
              {
                  r = (90000*100000*v*b)/(i*i);
               cout << "F( "<< i <<" )"<< " = "<< r << " \n ";
               ++i;
              }
              //cout <<i*i<<" \n ";
            cout << "FIN\n";
           }
            break;

             
        default:
             cout<<"grupo default de instrucciones \n";
      }
     
     // FIN DEL BUBLE WHILE
    } while (opcion!=0);
// FINAL DEL PROGRAMA

  return 0;
}

No hay comentarios:

Publicar un comentario