Tarea de 20 funciones, martes 24

Programación Orientada a Objetos (Tower defense - kingdom rush)

Moderator: julianmartinez16

User avatar
David Ballesteros V
Posts: 85
Joined: Fri Jul 22, 2016 11:04 am

Re: Tarea de 20 funciones, martes 24

Post by David Ballesteros V » Fri Jan 27, 2017 12:57 am

Code: Select all

class Program
    {
        public static double areatriang (double b, double h)
        {
            return b * h / 2;
        }
        public static int arearectan(int b, int h)
        {
            return b * h;
        }
        public static int suma (int a, int b)
        {
            return a + b;
        }
        public static int resta(int a, int b)
        {
            return a - b;
        }
        public static double numxnum(double a)
        {
            return a * a;
        }
        public static int producto(int a, int b)
        {
            return a * b;
        }
        public static double seno(double a)
        {
            return Math.Sin(a);
        }
        public static double coseno(double a)
        {
            return Math.Cos(a);
        }
        public static double division(double a, double b)
        {
            return a / b;
        }
        public static double tangente(double a)
        {
            return Math.Tan(a);
        }
        public static double potencia(double a, double b)
        {
            return Math.Pow(a, b);
        }
        public static double raiz(double a)
        {
            return Math.Sqrt(a);
        }
        public static double funcion(double a, double b, double c)
        {
            return (a + a) + (b * c);
        }
        public static double funcion2(int a, int b)
        {
            return a / (a * b);
        }
        public static double funcion3(int a, int b, int c)
        {
            return (a + c) / Math.Pow(b, 2);
        }
        public static double funcion4(double a, double b)
        {
            return ((Math.Cos(a)) + (Math.Sin(b)));
        }
        public static double funcion5(double a, double b)
        {
            return ((6 + a) - (2 + b));
        }
        public static double funcion6(double a, double b)
        {
            return ((Math.Pow(a, 2)) + (Math.Pow(b, b)));
        }
        public static double logaritmo(double a)
        {
            return Math.Log(a);
        }
        public static double log_natural(double a)
        {
            return Math.Log10(a);
        }
        
        
        static void Main(string[] args)
        {
           
            int r2,r3, r4, r6;
            double r1, r5, r7, r8, r9, r10, r11, r12, r13, r14, r15, r16, r17, r18, r19, r20;

            r1 = areatriang(10.1,5);
            r2 = arearectan(4,6);
            r3 = suma(3, 7);
            r4 = resta(20, 9);
            r5 = numxnum(2154);
            r6 = producto(7,9);
            r7 = seno(170);
            r8 = coseno(250);
            r9 = division(64, 8);
            r10 = tangente(34);
            r11 = potencia(5, 5);
            r12 = raiz(420);
            r13 = funcion(2.47, 5, 100);
            r14 = funcion2(7, 50);
            r15 = funcion3(10, 46, 3);
            r16 = funcion4(2.30, 70);
            r17 = funcion5(1.5, 23);
            r18 = funcion6(5.0, 12);
            r19 = logaritmo(2.5);
            r20 = log_natural(42);

            Console.WriteLine("Funciones");
            Console.WriteLine("-El área del triangulo es: "+r1);
            Console.WriteLine("-El área del rectangulo es: "+r2);
            Console.WriteLine("-La suma es: "+r3);
            Console.WriteLine("-La resta es: "+r4);
            Console.WriteLine("-La multiplicación es: "+r5);
            Console.WriteLine("-El producto es: "+r6);
            Console.WriteLine("-El seno sería: "+r7);
            Console.WriteLine("-El coseno sería: "+r8);
            Console.WriteLine("-La división es: "+r9);
            Console.WriteLine("-La tangente sería: "+10);
            Console.WriteLine("-La potencia es: "+r11);
            Console.WriteLine("-La raiz es: "+12);
            Console.WriteLine("-La primer función es: "+13);
            Console.WriteLine("-La segunda función es: "+14);
            Console.WriteLine("-La tercer función es: "+15);
            Console.WriteLine("-La cuarta función es: "+16);
            Console.WriteLine("-La quinta función es: "+17);
            Console.WriteLine("-La sexta función es: "+18);
            Console.WriteLine("-El logaritmo es: "+19);
            Console.WriteLine("-El logaritmo natural es: "+20);

            Console.ReadKey();
        }
    }
David Ballesteros Villa
Fundamentos De Programación - P.O.O

-Contacto:
Correo: Personal: dsktod@gmail.com Institucional: david.ballesteros@upb.edu.co
Redes: www.instagram.com/davidballev

User avatar
adrian.avila
Posts: 65
Joined: Tue Jan 19, 2016 12:23 pm

Re: Tarea de 20 funciones, martes 24

Post by adrian.avila » Fri Jan 27, 2017 12:59 am

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

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


double rsum = Sumar(6, 9);
double rrest = Restar(23, 12);
double rmul = Multiplicar(4, 9);
double rdiv = Dividir(22, 11);
double rpote = Potencia2(8);
double rdif = DiferentesDigitos(8, 9);
double rigu = IgualesDigitos(5, 7);
double rprom = Promedio(5,4,8);
double rpromcu = PromedioCuadrado(7,3,6);
double rnumma = NumMayor(5,3);
double rnumme = NumMenor(4, 7);
double rnummacu = NumMayorCuadrado(3,4);
double rnummecu = NumMenorCuadrado(6,8);
double raretri = AreaTriangulo(4, 6);
double rareci = AreaCirculo (3);
double rarecu = AreaCuadrado(8);
double rlongi = LongitudCirculo(7);
double rpita = Pitagoras(8,7);
double rdola = DolarAPeso(20);
double rarecil = AreaCilindro(6,7);


Console.WriteLine(" la suma es =" + rsum);
Console.WriteLine(" la resta es =" + rrest);
Console.WriteLine(" la multiplicacion = " + rmul);
Console.WriteLine(" la division es = " + rdiv);
Console.WriteLine(" la potencia es = " + rpote);
Console.WriteLine(" la diferencia de digito = " + rdif);
Console.WriteLine(" la igualdad de digito es = " + rigu);
Console.WriteLine(" el promedio es = " + rprom);
Console.WriteLine(" el promedio cuadrado es =" + rpromcu);
Console.WriteLine(" el numero mayor es = " + rnumma);
Console.WriteLine(" el numero menor es = " + rnumme);
Console.WriteLine(" el cuadrado del numero mayor es =" + rnummacu);
Console.WriteLine(" el cuadrado del numero menor es = " + rnummecu);
Console.WriteLine(" el area del triangulo es = " + raretri);
Console.WriteLine(" el area del circulo es = " + rareci);
Console.WriteLine(" el area del cuadrado es = " + rarecu);
Console.WriteLine(" la longitud del circulo es = " + rlongi);
Console.WriteLine(" la hipotenusa es = " + rpita);
Console.WriteLine(" la conversion dolar a peso colombiano es = " + rdola);
Console.WriteLine(" el area del cilindro es = " + rarecil);
}

public static double Sumar(double a, double b){

double c;
c= a + b;
return c;
}

public static double Restar(double a, double b) {

double c;

c = a - b;
return c;
}

public static double Multiplicar(double a, double b) {
double c;
c= a*b;
return c;
}

public static double Dividir(double a, double b) {
double c;
c = a / b;
return c;
}
public static double Potencia2 (double a){

a = a * a;

return a;
}

public static double DiferentesDigitos(double a1, double a2)
{
double c;
if (a1 != a2)
{
c = 1;
}

else
{
c = 2;
}
return c;
}

public static double IgualesDigitos(double a1, double a2)
{
double c;
if (a1== a2)
{
c = 1;
}

else
{
c = 2;
}
return c;
}
public static double Promedio(double a, double b, double c){
double prom;
prom = (a + b + c) / 3;
return prom;
}

public static double PromedioCuadrado(double a, double b, double c){
double prom;
prom = (a + b + c) / 3;
prom = prom * prom;
return prom;
}

public static double NumMayor(double a, double b)
{
if (a > b) {
return a;
} else {

return b;
}
}

public static double NumMenor(double a, double b)
{
if (a < b) {

return a;
} else {

return b;
}
}

public static double NumMayorCuadrado(double a, double b)
{
if (a > b) {
a = a * a;
return a;
} else {
b = b * b;
return b;
}
}

public static double NumMenorCuadrado(double a, double b)
{
if (a < b) {
a = a * a;
return a;
} else {
b = b * b;
return b;
}
}

public static double AreaTriangulo(double b, double h)
{
double are;
are = (b * h) / 2;
return are;

}

public static double AreaCuadrado(double l)
{
double are;
are = l * l;
return are;

}

public static double AreaCirculo(double R)
{
double are;
are = (R*R)*3.14;
return are;

}


public static double LongitudCirculo(double D)
{
double lon;
lon = D*3.14;
return lon;

}
public static double Pitagoras(double c1, double c2)
{

double hipo;

hipo = Math.Sqrt((c1* c1) + (c2 * c2));
return hipo;
}


public static double DolarAPeso (double dolar){

double pesos;

pesos = dolar * 2900;
return pesos;

}

public static double AreaCilindro(double R, double h)
{

double are;
are = 2 * 3.14 * R * (h + R);
return are;
}


}
}

Image

imagen :
https://68.media.tumblr.com/8e9dd3b28db ... 1_1280.png

#Si,UsoMac

User avatar
alejandra.roa
Posts: 35
Joined: Tue Jan 19, 2016 12:23 pm

Re: Tarea de 20 funciones, martes 24

Post by alejandra.roa » Fri Jan 27, 2017 1:12 am

Code: Select all

using System;
					
public class Program
{
	public static void Main()
	{
		Console.WriteLine("Funciones");
		int x = Suma(5,9);
		int z = Cuadrado(2);
		double y = Resta (6,1);
		float v = Velocidad (40,2);
		double u = Rectangulo (8, 96);
		double q = Division (7/45);
		double w = Cubo (4);
		int e = Mayor (7,3);
		double r = Menor (8,9);
		double t = Seno (0);
		double i = Coseno (1);
		double o = Tangente (-1);
		double p = RaizCuadrada (4);
		double a = Logaritmo (89);
		double s = Exponenciales (52);
		double d = Hipotenusa (2,4);
		double f = Circulo (9);
		int g = Promedio (5,96,10);
		double h = Cilindro (51,2);
		
		
}
	public static int Suma (int a, int b){
	int c;
	c= a+b;
		return c;
}
	public static int Cuadrado (int a){
	int c;
	c=a*a;
		return c;
}
	public static double Resta (int a, int b) {
	int c;
	c= a-b;
		return c;
}
	public static float Velocidad (int distancia, int tiempo){
	int c;
	c= distancia * tiempo;
		return c;
	}
	public static double Rectangulo (double base1, double altura){
	double c;
	c = base1 * altura;
		return c;
	}
	public static double  Division (double a, double b){
	double  c;
	c= a/b;
		return c;
	}
	public static double Cubo (double a){
	double c;
	c= a*a*a;
		return c;
	}
	public static int Mayor (int n1, int n2){
		if (n1>n2)
			return n1;
		else n2;
		
	}
	public static double Menor (double n1, double n2){
		if (n1<n2)
			return n1;
		else n2;
	}
	public static double Seno(double a)
   
   {
      return Math.Sin(a);
	}
	public static double Coseno (double b)
	{
		return Math.Cos(b);
	}
	public static double Tangente (double c)
	{
		return Math.Tan(c);
	
	}
	public static double RaizCuadrada (double a)
	{
		return Math.Sqrt(a);
	}
	public static double Logaritmo (double b)
	{
		return Math.Log(b);
	}
	public static double Exponenciales (double c)
	{
		return Math.Exp(c);
	}
	public static double Hipotenusa (double cateto1, double cateto2)
	{
		return Math.Sqrt(cateto1 * cateto1 + cateto2 * cateto2); 
	}
	public static double Circulo (double radio){
	double c;
		c = 3.14 * Math.Exp(radio);
		return c;
	
	} 
	public static int Promedio (int a, int b, int c){
	int x;
		x = ((a+b+c)/3);
		return x;
	}
	public static double Cilindro (double radio, double altura){
	double c;
		c = 2 * 3.14 * radio * (radio + altura);
	return c;	
	
	}
	public static void Despedida (){
	
		Console.WriteLine("Adios loks");
	}
}
	

User avatar
David Moscoso
Posts: 1
Joined: Sat Jan 21, 2017 8:43 pm

Re: Tarea de 20 funciones, martes 24

Post by David Moscoso » Fri Jan 27, 2017 8:42 am

using System;

public class Program
{


public static void Main(String[] args){

int sumAB=suma(5,5);


Console.WriteLine("Tarea 20 Funciones");
Console.WriteLine("Función 1: {0}", sumAB);
texto();
mover();
cuentaNumeros();
final();


}

static int suma (int valor1, int valor2){

int resultadoSuma= valor1 + valor2;
return resultadoSuma;
}

static void texto (){
Console.WriteLine("Esta es la función Numero 2");
}

static void mover(){
Console.WriteLine("te desplazaste a la izquierda con la función 3");

}

static void cuentaNumeros (){

for (int i = 1; i < 6; i++)
{
Console.Write("La función 4 cuenta numeros:");

Console.WriteLine("{0}|", i);

}
}
static void final(){
Console.WriteLine("Parece que no terminaste. Solo hiciste 5 Funciones");

Console.WriteLine("Game Over");
}

}

Post Reply