EVAP4

#include<iostream>
using namespace std;

int main()
{
    
    int  i, n, suma, opcion;
do
      {

     cout<<endl;
     cout<<"*****************************************\n";
    cout <<"MENU PRINCIPAL\n";   
     cout<<"1) SUMA DE LOS PRIMEROS NUMEROS NATURALES \n";
     cout<<"2) SUMA DE NUMEROS AL CUBO  \n";
     cout<<"3) SUMA DE NUMEROS AL CUADRADO \n";
     cout<<"4) SUMA DE LOS MULTIPLOS DE 3  \n";
     cout<<"5) SUMA DE NUMEROS IMPARES  \n";
     cout<<"6) SUMA DE NUMEROS PARES  \n";
     cout<<"7)  SUMA DE NUMEROS IMPARES MAYORES A 70 \n";
     cout<<"8) SUMA DE NUMEROS IMPARES MAYORES A  80  \n";
     cout<<"9) SUMA DE NUMEROS PARES MAYORES A 20  \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 <<"SUMA DE LOS PRIMEROS NUMEROS NATURALES";   
    cout<<endl;
    cout <<"INGRESE EL NUMERO DE TERMINOS A SUMAR: "; 
   cin >>n;
   cout<<endl;
   for (i=1; i<=n; i++)
    {
        suma = suma + i;
    }
     //Resultado
       cout <<  "LA SUMA DE LOS PRIMEROS NUMEROS NATURALES ES: "<< suma;
      cout<<endl;

                break;
                }
             case 2:
              {
                    suma=0;
     i = 1;
   cout<<endl;
    cout <<" SUMA DE NUMEROS AL CUBO ";   
    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 <<"SUMA DE NUMEROS AL CUADRADO";   
    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 4:
                        {cout <<"SUMA DE LOS MULTIPLOS DE 3";   
   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 + (3*i);
        i= i + 1;
    }
     //Resultado
       cout <<  "LA SUMA DE LOS MULTIPLOS DE 3: "<< suma;
      cout<<endl;
break;
                        }
        case 5:
             {cout <<"SUMA DE NUMEROS IMPARES ";   
   cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS A SUMAR:";   
cin >>n;
cout<<endl;
  suma=0;
        i = 1;
    while (i<=n) 
    {
        suma = suma + (2*i)-1;
        i= i + 1;
    }
     //Resultado
       cout <<  "LA SUMA DE LOS NUMEROS IMPARES: "<< suma;
      cout<<endl;
break;
                        }
        case 6:
             {cout <<"SUMA DE NUMEROS PARES";   
   cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS A SUMAR:";   
cin >>n;
cout<<endl;
        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 7:
                {    cout << "SUMA DE NUMEROS IMPARES MAYORES A  70";   
   cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS"; 
     cout<<endl;
     cout<<"EL NUMERO DE TERMINOS QUE INGRESE SERA TOMADO APARTIR DE 70:"; 
cin >>n;
cout<<endl;
  
        suma=0;
        i = 1;
    do
    {
        suma = suma+ 70 +(2*i)-1;
        i= i + 1;
    }
    while (i<=n);
       cout <<  "LA SUMA ES "<< suma;
      cout<<endl;
break; 
                   }
         
 case 8:
               {    cout << "SUMA DE NUMEROS IMPARES MAYORES A  80";   
   cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS"; 
     cout<<endl;
     cout<<"EL NUMERO DE TERMINOS QUE INGRESE SERA TOMADO APARTIR DE 80:"; 
cin >>n;
cout<<endl;
  
        suma=0;
        i = 1;
    do
    {
        suma = suma+ 80 +(2*i)-1;
        i= i + 1;
    }
    while (i<=n);
       cout <<  "LA SUMA ES "<< suma;
      cout<<endl;
break;
                        }
      case 9:
             {    cout << "SUMA DE NUMEROS PARES MAYORES A 20 ";   
   cout<<endl;
    cout <<"INGRESE EL NUMERO TERMINOS"; 
     cout<<endl;
     cout<<"EL NUMERO DE TERMINOS QUE INGRESE SERA TOMADO APARTIR DE 20:"; 
cin >>n;
cout<<endl;
  
        suma=0;
        i = 1;
    do
    {
        suma = suma+ 20 +(2*i);
        i= i + 1;
    }
    while (i<=n);
       cout <<  "LA SUMA ES "<< suma;
      cout<<endl;
break;
                        }                             
         }
        cout<<endl;
      
 }
  while (opcion != 0);         

        system("pause");
        return 0;
  }

No hay comentarios:

Publicar un comentario