Factorial de un numero


using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {
            double n, factorial = 1, i;
            int op;
            do
            {
            Console.WriteLine("Ingresar el número deceado");
            n = double.Parse(Console.ReadLine());
            if (n >= 0)
            {
                for (i = 1; i <= n; i++)
                {
                    factorial = factorial * i;
                }
                Console.WriteLine("El factorial de dicho número es:");
                Console.WriteLine(factorial);
                Console.ReadLine();
            }
            else
                Console.WriteLine("operacion no valida");

            Console.WriteLine("DECEAS CONTINUAR CON LA OPERACION");
               
                Console.WriteLine("(1)<---------------------->SI");
                Console.WriteLine("(2)<---------------------->NO");
            op = int.Parse(Console.ReadLine());
            Console.Clear();
         }
           while (op == 1);
       }
    }
}

Cantidad de Divisores de un Numero


using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication7
{
    class Program
    {
        static void Main(string[] args)
        {
           
            int num;
            int cont=0;
            Console.WriteLine("Ingrese un numero");
            num = int.Parse(Console.ReadLine());
            for (int i = 1; i <= num; i++)
            {
                   if (num%i==0)
                    {
                       cont = cont + 1;
                     
                   
                    }
                 
                           
            }
                Console.WriteLine("La cantidad de divisores de es: {0}", cont);
            Console.ReadLine();
        }
    }
}

Base


 int b1, b2;
            double n1;
            Console.WriteLine("Ingresar numero a convertir");
            n1 = double.Parse(Console.ReadLine());
            Console.WriteLine("Ingresar la base del numero a convertir");
            b1 = int.Parse(Console.ReadLine());
            Console.WriteLine("Ingresar la base al que se desea convertir");
            b2 = int.Parse(Console.ReadLine());
            if (n1 < b1)
            {




            Console.ForegroundColor = ConsoleColor.Red;
            Console.BackgroundColor = ConsoleColor.White;
            Console.WriteLine("*****Productos---Edimir & Michael*****");
            Console.WriteLine("");



int num;
            byte bas1, bas2;
            int res;
            Console.WriteLine("ingresar número en base 10");
            num = int.Parse(Console.ReadLine());
            Console.WriteLine("ingresar base menor a 10 ");
            bas1 = byte.Parse(Console.ReadLine());
            while (bas1 <= 10)
            {
                Console.WriteLine("ingresar base a convertir");
                bas2 = byte.Parse(Console.ReadLine());

                while (num > 0)
                {
                    res = num % bas1;
                    Console.Write(res);
                    num = num / bas1;
                }
            }

            Console.ReadLine();

Capicuo


using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication3
{
    class Program
    {
        static void Main(string[] args)
        {

            Console.ForegroundColor = ConsoleColor.Yellow;
            int n, op;
            string cadena = "", fra="";
            do
            {
                Console.WriteLine("Ingrese la frase:");
                cadena = Console.ReadLine();
                Console.WriteLine("Al reves es:");
                n = (cadena.Length) - 1;
                for (int i = n; i >= 0; i = i - 1)
                {
                    fra = fra + cadena.Substring(i, 1);
                }
                Console.WriteLine(fra);
                if (cadena.CompareTo(fra) == 0)
                {
                    Console.WriteLine("Es capicuo");
                }
                else
                {
                    Console.WriteLine("No es capicuo");
                }
               
                Console.WriteLine("");
                Console.WriteLine("Desea seguir probando????...si(presione 1), bye(presione 2)");
                op = int.Parse(Console.ReadLine());
                Console.Clear();
            }
            while (op == 1);
        }
    }
}

Promedio de Notas de Alumnos


int num;
            float suma, promcurso = 0, n1, curso, cantidad;
            string[] nombre = new string[100];
            float[] promedio = new float[100];
            float[] nota = new float[20];
            string grado = "";
            Console.WriteLine("Ingrese el numero de alumno");
            num = int.Parse(Console.ReadLine());
            //ingreso de datos//
            for (int i = 0; i < num; i++)
            {
                Console.WriteLine("Ingresar el nombre del alumno{0}:", i + 1);
                nombre[i] = Console.ReadLine();
                Console.Write("Ingrese la cantidad de curso{0}:", i + 1);
                cantidad = float.Parse(Console.ReadLine());

                n1 = 0;
                for (int j = 1; j <= cantidad; j++)
                {
                    Console.WriteLine("ingresar la nota del curso {0}", j);
                    curso = float.Parse(Console.ReadLine());
                    n1 = n1 + curso;
                }
                promcurso = n1 / cantidad;
                nota[i] = promcurso;
            }

            //mostrar resultados//
            for (int i = 0; i < num; i++)
            {
                Console.WriteLine(i + 1);
                Console.WriteLine("El nombre es:");
                Console.WriteLine(nombre[i]);
                Console.WriteLine("La nota es:");
                Console.WriteLine(nota[i]);
                if (nota[i] > 10)
                {
                    grado = "APROBADO";
                }
                  if (nota[i] <= 10)
                    {
                        grado = "DESAPROBADO";
                    }
            }
            Console.WriteLine("La condicion es: {0}", grado);
            Console.ReadLine();
...........................
int num=0;
            float suma = 0, promcurso = 0, n1, curso, cantidad, sumab=0, peso;
            string[] nombre = new string[100];
            float[] promedio = new float[100];
            float[] nota = new float[20];
            string grado = "";
            int op1, op2, f=0;
            do
            {
                Console.Clear();
                Console.WriteLine("1...Nuevo Alumno");
                Console.WriteLine("2...Lista");
                Console.WriteLine("0...Salir");
                Console.Write("Ingrese opcion");
                op1 = int.Parse(Console.ReadLine());
                switch (op1)
                {
                    case 1:
                        Console.WriteLine("Ingrese the name of studen{0}:");
                        nombre[f] = Console.ReadLine();
                        Console.Write("Ingrese la cantidad de curso{0}:");
                        cantidad = float.Parse(Console.ReadLine());

                        n1 = 0;
                        for (int j = 1; j <= cantidad; j++)
                        {
                            Console.WriteLine("Ingresar la nota del curso {0}", j);
                            curso = float.Parse(Console.ReadLine());
                            n1 = n1 + curso;
                            {
                                if ((nota[f] >= 0) && (nota[f] <= 20))
                                {
                                    Console.WriteLine("Ingrese el peso del curso {0}");
                                    peso = float.Parse(Console.ReadLine());
                                    suma = (suma + nota[f] * peso);
                                    sumab = sumab + peso;
                                }
                                else
                                {
                                    Console.WriteLine("Error, ingrese other value");
                                    Console.ReadLine();
                                }
                           
                            }
                       
                        }
                              promcurso = suma / sumab;
                            nota[f] = promcurso;
                            break;
             
                    case 2:
                        for (int i = 0; i < num; i++)
                        {
                            Console.WriteLine(i + 1);
                            Console.WriteLine("El nombre es:");
                            Console.WriteLine(nombre[i]);
                            Console.WriteLine("La nota es:");
                            Console.WriteLine(nota[i]);
                            if (nota[i] > 10)
                            {
                                grado = "APROVADO";
                            }
                            if (nota[i] <= 10)
                            {
                                grado = "DESAPROVADO";
                            }
                            break;
                        }
                        Console.WriteLine("La condicion es: {0}", grado);
                        Console.ReadLine();
                        Console.WriteLine("DECEA CONTINUAR SI(1), NO(2)");
                        op2 = int.Parse(Console.ReadLine());
                        Console.Clear();
                }

            }
            while (op1 != 1);

Un hombre desea saber cuanto dinero se genera por concepto de intereses sobre la cantidad que tiene en inversión en el banco. El decidirá reinvertir los intereses siempre y cuando estos excedan a S/.7000, y en ese caso desea saber cuanto dinero tendrá finalmente en su cuenta

Un hombre desea saber cuanto dinero se genera por concepto de intereses sobre la cantidad que tiene en inversión en el banco. El decidirá reinvertir los intereses siempre y cuando estos excedan a S/.7000, y en ese caso desea saber cuanto dinero tendrá finalmente en su cuenta

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ejercicio01
{
    class Hombre
    {
        private string nombre;
        private float dinero;
        public void Inicio()
        {
            Console.WriteLine("---------BANCO --------");
            Console.WriteLine("-----------------------------");
            Console.WriteLine("INGRESE SU NOMBRE: ");
            nombre = Console.ReadLine();
            Console.WriteLine("INGRESE SU MONTO DINERO; ");
            dinero = float.Parse(Console.ReadLine());
            Console.Clear();

        }
        public void Imprimir()
        {
            Console.WriteLine("---------BANCO --------");
            Console.WriteLine("-----------------------------");

            Console.WriteLine("NOMBRE:    " + nombre);

            if (dinero > 7000)
            {
                Console.WriteLine("USTED NO PUEDE EXCEDER EL MONTO DE S/ 7000");
            }
            else
            {
                Console.WriteLine("INVERSION: " + dinero);
            }
            Console.ReadLine();

        }
        static void Main(string[] args)
        {

            Hombre per = new Hombre();
            per.Inicio();
            per.Imprimir();

        }
    }
}

Reloj digital C#

Reloj digital C#

using System;
using System.Collections.Generic;
using System.Text;

namespace rellotgeDigitalAmbAlarma
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.ForegroundColor = ConsoleColor.Red;
            Console.BackgroundColor = ConsoleColor.Yellow;
            Console.Clear();
            int h, m, s, x;
            int alarmaH, alarmaM, alarmaS;
            String alarma;
            Console.WriteLine("Introdueix les hores");
            h = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Introdueix els minuts");
            m = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Introdueix els segons");
            s = Convert.ToInt32(Console.ReadLine());
            Console.WriteLine("Vols possar alarma, si o no");
            alarma = Convert.ToString(Console.ReadLine());


            if (alarma == "si")
            {
                Console.Clear();
                Console.WriteLine("Introdueix les hores de l'alarma");
                alarmaH = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Introdueix els minuts de l'alarma");
                alarmaM = Convert.ToInt32(Console.ReadLine());
                Console.WriteLine("Introdueix els segons de l'alarma");
                alarmaS = Convert.ToInt32(Console.ReadLine());

            }
            else
            {
                alarmaH = -1;
                alarmaM = -1;
                alarmaS = -1;
            }


            while (true)
            {
                Console.Clear();
                Console.WriteLine("Son les {0}:{1}:{2}", h, m, s);
                x = Environment.TickCount;
                while (Environment.TickCount <= x + 1000) ;
                s = s + 1;
                if (alarmaH == h && alarmaM == m && alarmaS == s)
                {
                    Console.Beep();
                    Console.Beep();
                    Console.Beep();

                }


                if (s == 60)
                {
                    s = 0;
                    m = m + 1;
                    if (m == 60)
                    {
                        m = 0;
                        h = h + 1;
                        if (h == 24)
                        {
                            h = 0;

                        }
                    }
                }




            }

        }

    }
}

Popular Posts