Facebook
From Diego Camacho, 4 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.         public static int f_sumador(int a, int b)
  9.         {
  10.  
  11.             int respuesta = a + b;
  12.  
  13.             return respuesta;
  14.  
  15.         }
  16.         public static int f_sumador2(int a, int b)
  17.         {
  18.  
  19.             int respuesta = a-b;
  20.  
  21.             return respuesta;
  22.  
  23.         }
  24.         public static int f_sumador3(int a, int b)
  25.         {
  26.  
  27.             int respuesta = a * b;
  28.  
  29.             return respuesta;
  30.  
  31.         }
  32.         public static int f_sumador4(int a, int b)
  33.         {
  34.  
  35.             int respuesta = a / b;
  36.  
  37.             return respuesta;
  38.  
  39.         }
  40.  
  41.         static void Main(string[] args)
  42.         {
  43.  
  44.             int numero1 = 0;
  45.             int numero2 = 0;
  46.             int operacion = 0;
  47.             int respuesta = 0;
  48.  
  49.             Console.WriteLine("Que operacion desea usar");
  50.             Console.WriteLine("1.suma 2.resta 3.multiplicacion 4.division");
  51.             operacion = Convert.ToInt32(Console.ReadLine());
  52.             if(operacion==1)
  53.             {
  54.                 Console.WriteLine("introduce numero 1");
  55.                 numero1 = Convert.ToInt32(Console.ReadLine());
  56.                 Console.WriteLine("introduce numero dos");
  57.                 numero2 = Convert.ToInt32(Console.ReadLine());
  58.                 respuesta = f_sumador(numero1, numero2 );
  59.                 Console.WriteLine("la respuesta es  {0}", respuesta);
  60.             }
  61.            else if (operacion == 2)
  62.             {
  63.                 Console.WriteLine("introduce numero 1");
  64.                 numero1 = Convert.ToInt32(Console.ReadLine());
  65.                 Console.WriteLine("introduce numero dos");
  66.                 numero2 = Convert.ToInt32(Console.ReadLine());
  67.                 respuesta = f_sumador2(numero1, numero2);
  68.                 Console.WriteLine("la respuesta es  {0}", respuesta);
  69.             }
  70.             else if (operacion == 3)
  71.             {
  72.                 Console.WriteLine("introduce numero 1");
  73.                 numero1 = Convert.ToInt32(Console.ReadLine());
  74.                 Console.WriteLine("introduce numero dos");
  75.                 numero2 = Convert.ToInt32(Console.ReadLine());
  76.                 respuesta = f_sumador3(numero1, numero2);
  77.                 Console.WriteLine("la respuesta es  {0}", respuesta);
  78.             }
  79.             else if (operacion == 4)
  80.             {
  81.                 Console.WriteLine("introduce numero 1");
  82.                 numero1 = Convert.ToInt32(Console.ReadLine());
  83.                 Console.WriteLine("introduce numero dos");
  84.                 numero2 = Convert.ToInt32(Console.ReadLine());
  85.                 respuesta = f_sumador4(numero1, numero2);
  86.                 Console.WriteLine("la respuesta es  {0}", respuesta);
  87.             }
  88.          
  89.          
  90.          
  91.          
  92.          
  93. -------------------------------------------------------------------------------------------------------------          
  94. --------------------------------------------------------------------------------------------------------------
  95.   ---------------------------------------------------------------------------------------------------------------
  96. using System;
  97.  
  98. namespace funciones
  99. {
  100.     class Program
  101.     {
  102.  
  103.         public static int f_sumador(int a, int b)
  104.         {
  105.  
  106.             int final1y2 = a + b;
  107.  
  108.             return final1y2;
  109.  
  110.         }
  111.         public static int f_sumador2(int c,int d)
  112.         {
  113.  
  114.             int final3 = ((((c+d)/3)*60)/100) ;
  115.  
  116.             return final3;
  117.  
  118.         }
  119.  
  120.         static void Main(string[] args)
  121.         {
  122.  
  123.             int parcial1 = 0;
  124.             int parcial2 = 0;
  125.             int parcial3 = 0;
  126.             int semestral = 0;
  127.             int final1y2 = 0;
  128.             int final3 = 0;
  129.  
  130.             Console.WriteLine("calificacion del primer parcial");
  131.             parcial1 = Convert.ToInt32(Console.ReadLine());
  132.  
  133.             Console.WriteLine("calificacion del segundo parcial");
  134.             parcial2 = Convert.ToInt32(Console.ReadLine());
  135.             final1y2 = f_sumador(parcial1, parcial2);
  136.  
  137.             Console.WriteLine("calificacion del tercer parcial");
  138.             parcial3 = Convert.ToInt32(Console.ReadLine());
  139.  
  140.             Console.WriteLine("calificacion del semestral");
  141.             semestral = Convert.ToInt32(Console.ReadLine());
  142.             semestral = (semestral * 40) / 100;
  143.  
  144.             final3 = f_sumador2(parcial3,final1y2);
  145.  
  146.             Console.WriteLine("la calificacion final es  {0}", final3+semestral);
  147.