Facebook
From Nicolas Abraham, 3 Years ago, written in C#.
This paste is a reply to Funciones from Ricardo Gaytán - view diff
Embed
Download Paste or View Raw
Hits: 239
  1. using System;
  2.  
  3. namespace funciones
  4. {
  5.     class Program
  6.     {
  7.  
  8.  
  9.         public static int cuadrado(int a, int b)
  10.         {
  11.  
  12.             int cua = a * b;
  13.  
  14.             return cua;
  15.  
  16.         }
  17.         public static int triangulo(int a, int b)
  18.         {
  19.  
  20.             double tri = (a * b) / 2;
  21.  
  22.             return Convert.ToInt16(tri);
  23.  
  24.         }
  25.         public static int circulo(int a)
  26.         {
  27.             double pi = 3.1416;
  28.             double circ = (Math.Pow (a,2) * pi);
  29.  
  30.             return Convert.ToInt16(circ);
  31.  
  32.         }
  33.         static void Main(string[] args)
  34.         {
  35.  
  36.  
  37.             double resultado = 0;
  38.             int lado1 = 0;
  39.             int opcion = 0;
  40.             int lado2 = 0;
  41.             int base1 = 0;
  42.             int altura = 0;
  43.             int radio = 0;
  44.             Console.WriteLine("1-Cuadrado");
  45.             Console.WriteLine("2-Triangulo");
  46.             Console.WriteLine("3-circulo");
  47.             Console.WriteLine("De que figura desea sacar el area");
  48.             opcion = Convert.ToInt32(Console.ReadLine());
  49.             switch (opcion)
  50.             {
  51.                 case 1:
  52.                     Console.WriteLine("Lado1= ");
  53.                     lado1 = Convert.ToInt32(Console.ReadLine());
  54.                     Console.WriteLine("Lado2= ");
  55.                     lado2 = Convert.ToInt32(Console.ReadLine());
  56.                     resultado = cuadrado(lado1, lado2);
  57.                     Console.WriteLine("El area es {0}",resultado);
  58.                     break;
  59.  
  60.                 case 2:
  61.                     Console.WriteLine("Altura= ");
  62.                     base1 = Convert.ToInt32(Console.ReadLine());
  63.                     Console.WriteLine("base= ");
  64.                     altura = Convert.ToInt32(Console.ReadLine());
  65.                     resultado = triangulo(base1, altura);
  66.                     Console.WriteLine("El area es {0}", resultado);
  67.                     break;
  68.                 case 3:
  69.                     Console.WriteLine("Radio ");
  70.                     radio = Convert.ToInt32(Console.ReadLine());
  71.                     resultado = circulo(radio);
  72.                     Console.WriteLine("El area es {0}", resultado);
  73.                     break;
  74.             }
  75.  
  76.  
  77.         }
  78.     }
  79. }

Replies to Re: Funciones rss

Title Name Language When
Re: Re: Segundo programa Nicolas Abraham csharp 3 Years ago.