EVAP 04

#include<iostream>
using namespace std;

int main()
{
    // DECLARACION
    int  i, n, suma, opcion,prod;
do //hacer
      {
// MENSAJE DE TEXTO DEL MENU
     cout<<endl;
     cout<<"*****************************************\n";
    cout <<"MENU PRINCIPAL\n";   
     cout<<"1) SUMA DE CUADRADOS \n";
     cout<<"2) SUMA DE CUBOS  \n";
     cout<<"3) SUMA DE LOS MULTIPLOS DE 4 \n";
     cout<<"4) SUMA DE LOS MULTIPLOS DE 5  \n";
     cout<<"5) SUMA DE NUMEROS PARES  \n";
     cout<<"6) SUMA DE NUMEROS NATURALES  \n";
     cout<<"7) PRODUCTO DE NUMEROS MAYORES A 20  \n";
     cout<<"8) SUMA DE NUMEROS IMPARES MAYORES A 30  \n";
     cout<<"9) SUMA DE NUMEROS DE 3 CIFRAS  \n";
     cout<<"                   DIGITE  <0> PARA SALIR\n";
     cout<<"*****************************************\n";
     cout<<"INGRESE LA OPCION : "; cin>>opcion; cout<<" \n";

     switch(opcion)
         {
             case 1:
                 {     suma=0;
     i = 1;
   cout<<endl;
    cout <<"CALCULO DE LA SUMA DE LOS PRIMEROS CUADRADOS";   
    cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS A SUMAR: "; 
//ASIGNACION
   cin >>n;
   cout<<endl;
   //Proceso repetitivo finito
    for (i=1; i<=n; i++)
    {
        suma = suma + (i*i);
    }
     //Resultado
       cout <<  "LA SUMA DE LOS PRIMEROS CUADRADOS ES: "<< suma;
      cout<<endl;

                break;
                }
             case 2:
              {
                   suma=0;
     i = 1;
   cout<<endl;
    cout <<"CALCULO DE LA SUMA DE LOS PRIMEROS CUBOS";   
    cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS A SUMAR: "; 
//ASIGNACION
   cin >>n;
   cout<<endl;
   //Proceso repetitivo finito
    for (i=1; i<=n; i++)
    {
        suma = suma + (i*i*i);
    }
     //Resultado
       cout <<  "LA SUMA DE LOS PRIMEROS CUBOS ES: "<< suma;
      cout<<endl;

                break;
               }
         case 3:
              {     suma=0;
     i = 1;
   cout<<endl;
    cout <<"CALCULO DE LA SUMA DE LOS PRIMEROS MULTIPLOS DE 4";   
    cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS A SUMAR: "; 
//ASIGNACION
   cin >>n;
   cout<<endl;
   //Proceso repetitivo finito
    for (i=1; i<=n; i++)
    {
        suma = suma + (4*i);
    }
     //Resultado
       cout <<  "LA SUMA DE LOS PRIMEROS MULTIPLOS DE 4 ES: "<< suma;
      cout<<endl;
    
      break;
                   }
                   case 4:
                        {cout <<"CALCULO DE LA SUMA DE LOS MULTIPLOS DE 5";   
   cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS A SUMAR:";   
cin >>n;
cout<<endl;
   //Proceso repetitivo
   //inicializar acumuladores
        suma=0;
        i = 1;
    while (i<=n) 
    {
        suma = suma + (5*i);
        i= i + 1;
    }
     //Resultado
       cout <<  "LA SUMA DE LOS MULTIPLOS DE 5: "<< suma;
      cout<<endl;
break;
                        }
        case 5:
             {cout <<"CALCULO DE LA SUMA DE LOS NUMEROS PARES";   
   cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS A SUMAR:";   
cin >>n;
cout<<endl;
   //Proceso repetitivo
   //inicializar acumuladores
        suma=0;
        i = 1;
    while (i<=n) 
    {
        suma = suma + (2*i);
        i= i + 1;
    }
     //Resultado
       cout <<  "LA SUMA DE LOS NUMEROS PARES: "<< suma;
      cout<<endl;
break;
                        }
        case 6:
             {    cout <<"SUMATORIA DE NUMEROS NATURALES";   
   cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS A SUMAR:";   
cin >>n;
cout<<endl;
   //Proceso repetitivo
   //inicializar acumuladores
        suma=0;
        i = 1;
    while (i<=n) 
    {
        suma = suma + (i);
        i= i + 1;
    }
     //Resultado
       cout <<  "LA SUMA ES: "<< suma;
      cout<<endl;
break;
                        }
        case 7:
             {    cout <<"CALCULO DEL PRODUCTO DE LOS NUMEROS MAYORES A 20";   
   cout<<endl;
    cout <<"INGRESE EL NUMERO DE TERMINOS QUE DESEA MULTIPLICAR"; 
     cout<<endl;
     cout<<"EL NUMERO DE TERMINOS QUE INGRESE SERA TOMADO APARTIR DE 20:"; 
cin >>n;
cout<<endl;
  
  //inicializar acumuladores
        prod=1;
        i = 1;
    do
    {
        prod = prod * (20+i);
        i= i + 1;
    }
    while (i<=n);
     //Resultado
       cout <<  "EL PRODUCTO "<< prod;
      cout<<endl;
break;
                        }
          case 8:
               {    cout <<"CALCULO DE LA SUMA DE NUMEROS IMPARES MAYORES A 30";   
   cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS"; 
     cout<<endl;
     cout<<"EL NUMERO DE TERMINOS QUE INGRESE SERA TOMADO APARTIR DE 30:"; 
cin >>n;
cout<<endl;
  
   //inicializar acumuladores
        suma=0;
        i = 1;
    do
    {
        suma = suma+ 30+(2*i)-1;
        i= i + 1;
    }
    while (i<=n);
     //Resultado
       cout <<  "LA SUMA ES "<< suma;
      cout<<endl;
break;
                        }
      case 9:
           {    cout <<"SUMATORIA DE NUMEROS DE 3 CIFRAS";   
   cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS"; 
     cout<<endl;
     cout<<"LA SUMA SE REALIZA DESDE 100 PARA ARRIBA:"; 
cin >>n;
cout<<endl;
   if (n<=999)
   {
   //inicializar acumuladores
        suma=0;
        i = 1;
    do
    {
        suma = suma+ 99+ i;
        i= i + 1;
    }
    while (i<=n);
     //Resultado
       cout <<  "LA SUMA ES "<< suma;
      cout<<endl;
      }
      else
      {
           cout<<"INGRESE UN NUMERO ENTRE 1 Y 999";
           cout<<endl;
           }
break;
                        }                             
         }
        cout<<endl;
      
 }
  while (opcion != 0);         

        system("pause");
        return 0;
  }

No hay comentarios:

Publicar un comentario