Está en la página 1de 34

Ejercicio N 01

El siguiente ejercicio nos pedir ingresar la velocidad de un mvil y


el tiempo usado por el mvil, calcularemos la distancia recorrida y
mostraremos el resultado del total de la distancia recorrida.

Para hacer nuestro ejercicio 01 lo primero que haremos es ingresar


los comandos que vamos a utilizar:
Label1
Label2
Label3
Label4
Textbox1
Textbox2
Textbox3
Button 1
Button 2
Button 3

En la siguiente imagen observamos los comandos que utilizaremos.


En esta imagen tenemos el codigo del programa. Si lo observamos nos daremos
cuenta que los textbox solo los declaramos como variables y en el button1 esta la
operacion para calcular la distancia.

Al tener el codigo listo ya podemos empezar la copilacion de nuestro programa como


lo muestra la siguiente imagen.
Ejercicio N 02
Primero crearemos un nuevo proyecto llamado Ejercicio02. En este
ejercicio nos pedira ingresar 3 notas y calculara el promedio de ellas.
Para esto necesitaremos:

Ingresar 5 label
Ingresar 4 textbox
Ingresar 3 button.

Ingresaremos los nombres a los label y asi mismo a los button, en


este caso utilice 3 button 1 para calcular el promedio, el 2do para
limpiar la pantalla y el 3ro para detener la copilacion.
Ejercicio N 03:

El ejercicio 03 nos pedira ingresar respuestas correctas e incorrectas y nos mostrara el puntaje
total.
Por cada respuesta correcta obtendra 4 puntos y si esta mala tendra -1 punto.
Ingresaremos los comandos que utilizaremos.
Ejercicio N 04:
El siguiente ejercicio nos pedira ingresar partidos ganados y partidos empatados.
Agregaremos los comandos que vamos a utilizar.
Ejercicio N 05:
El ejercicio 05 nos servira para calcular el pago del trabajador multiplicando horas
laboradas * tarifa por cada hora trabajada.

Ingresaremos los comandos que vamos a utiliza:


4 label
3 textbox
3 button

Despues en los label ingresaremos los nombres que deseemos agregarles, si desean
se pueden ayudar con la imagen.
Ejercicio N 06:
El siguiente eejercicio pedira ingresar cuantro miden los tres lados de cualquier clase de
triangulos, luego tendra que mostrar el semiperimetro y el area total.
Matricessssssssssssssss
Crear una matriz de 3 filas por 5 columnas con elementos de tipo int, cargar sus
componentes y luego imprimirlas.

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

namespace Matriz1
{
class Matriz1
{
private int[,] mat;

public void Cargar()


{
mat=new int[3,5];
for(int f = 0;f < 3;f++)
{
for(int c = 0;c < 5;c++)
{
Console.Write("Ingrese
componente:");
string linea;
linea = Console.ReadLine();
mat[f,c]=int.Parse(linea);
}
}
}

public void Imprimir()


{
for(int f = 0;f < 3;f++)
{
for(int c = 0;c < 5;c++)
{
Console.Write(mat[f,c]+" ");
}
Console.WriteLine();
}
Console.ReadKey();
}

static void Main(string[] args)


{
Matriz1 ma = new Matriz1();
ma.Cargar();
ma.Imprimir();
Crear y cargar una matriz de 4 filas por 4 columnas. Imprimir la diagonal principal.

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

namespace Matriz2
{
class Matriz2
{
private int[,] mat;

public void Cargar()


{
mat=new int[4,4];
for(int f = 0; f < 4; f++)
{
for(int c = 0; c<4; c++)
{
Console.Write("Ingrese
componente:");
string linea;
linea = Console.ReadLine();
mat[f, c] =
int.Parse(linea);
}
}
}

public void ImprimirDiagonalPrincipal()


{
for(int k = 0; k < 4; k++)
{
Console.Write(mat[k,k]+" ");
}
Console.ReadKey();
}

static void Main(string[] args)


{
Matriz2 ma = new Matriz2();
ma.Cargar();
ma.ImprimirDiagonalPrincipal();

Crear y cargar una matriz de 3 filas por 4 columnas. Imprimir la primer fila. Imprimir la
ltima fila e imprimir la primer columna.

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

namespace Matriz3
{
class Matriz3
{
private int[,] mat;

public void Cargar()


{
mat=new int[3,4];
for(int f = 0; f < 3; f++)
{
for(int c = 0; c < 4; c++)
{
Console.Write("Ingrese
componente:");
string linea;
linea = Console.ReadLine();
mat[f,c]=int.Parse(linea);
}
}
}

public void PrimerFila()


{
Console.WriteLine("Primer fila de la
matriz:");
for(int c = 0; c < 4; c++)
{
Console.WriteLine(mat[0,c]);
}
}

public void UltimaFila()


{
Console.WriteLine("Ultima fila de la
matriz:");
for(int c = 0; c < 4; c++)
{
Console.WriteLine(mat[2,c]);
}
}

public void PrimerColumna()


{
Console.WriteLine("Primer columna:");
for(int f = 0; f < 3; f++)
{
Console.WriteLine(mat[f,0]);
}
}

static void Main(string[] args)


{
Matriz3 ma = new Matriz3();
ma.Cargar();
ma.PrimerFila();
ma.UltimaFila();
ma.PrimerColumna();
Console.ReadKey();
Crear una matriz de n * m filas (cargar n y m por teclado) Imprimir el mayor elemento y
la fila y columna donde se almacena.

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

namespace Matriz6
{
class Matriz6
{
private int[,] mat;

public void Cargar()


{
Console.Write("Cuantas fila tiene la
matriz:");
string linea;
linea=Console.ReadLine();
int filas=int.Parse(linea);
Console.Write("Cuantas columnas
tiene la matriz:");
linea=Console.ReadLine();
int columnas=int.Parse(linea);
mat=new int[filas,columnas];
for(int f = 0; f < mat.GetLength(0);
f++)
{
for(int c = 0; c <=""
mat.getlength(0);="" f++)="" c="0;"
mat.getlength(1);="" if="" (mat[f,c]=""> mayor)
{
mayor=mat[f,c];
filamay=f;
columnamay=c;
}
}
}
Console.WriteLine("El elemento mayor
es:"+mayor);
Console.WriteLine("Se encuentra en
la fila:"+filamay+ " y en la columna:
"+columnamay);
Console.ReadLine();
}

static void Main(string[] args)


{
Matriz6 ma = new Matriz6();
ma.Cargar();
ma.ImprimirMayor();

1. Crear una matriz de n * m filas (cargar n y m por teclado) Intercambiar la


primer fila con la segundo. Imprimir luego la matriz.
2. Crear una matriz de n * m filas (cargar n y m por teclado) Imprimir los
cuatro valores que se encuentran en los vrtices de la misma (mat[0][0]
etc.)

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

namespace Matriz7
{
class Matriz7
{
private int[,] mat;

public void Cargar()


{
Console.Write("Cuantas fila tiene la matriz:");
string linea;
linea=Console.ReadLine();
int filas=int.Parse(linea);
Console.Write("Cuantas columnas tiene la
matriz:");
linea=Console.ReadLine();
int columnas=int.Parse(linea);
mat=new int[filas,columnas];
for(int f = 0; f < mat.GetLength(0); f++)
{
for(int c = 0;c < mat.GetLength(1); c++)
{
Console.Write("Ingrese componente:");
linea = Console.ReadLine();
mat[f,c]=int.Parse(linea);
}
}
}

public void Intercambiar()


{
for (int c = 0; c < mat.GetLength(0); c++)
{
int aux = mat[0,c];
mat[0,c] = mat[1,c];
mat[1,c] = aux;
}
}

public void Imprimir()


{
for(int f = 0; f < mat.GetLength(0); f++)
{
for(int c = 0; c < mat.GetLength(1); c++)
{
Console.Write(mat[f,c]+" ");
}
Console.WriteLine();
}
Console.ReadKey();
}

static void Main(string[] args)


{
Matriz7 ma = new Matriz7();
ma.Cargar();
ma.Intercambiar();
ma.Imprimir();
}
}
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace Matriz8
{
class Matriz8
{
private int[,] mat;

public void Cargar()


{
Console.Write("Cuantas fila tiene la matriz:");
string linea;
linea=Console.ReadLine();
int filas=int.Parse(linea);
Console.Write("Cuantas columnas tiene la
matriz:");
linea=Console.ReadLine();
int columnas=int.Parse(linea);
mat=new int[filas,columnas];
for(int f = 0; f < mat.GetLength(0); f++)
{
for(int c = 0; c < mat.GetLength(1); c++)
{
Console.Write("Ingrese componente:");
linea = Console.ReadLine();
mat[f,c]=int.Parse(linea);
}
}
}

public void ImprimirVertices()


{
Console.WriteLine("Vrtice superior
izquierdo:");
Console.WriteLine(mat[0,0]);
Console.WriteLine("Vrtice superior derecho:");
Console.WriteLine(mat[0,mat.GetLength(1)-1]);
Console.WriteLine("Vrtice inferior
izquierdo:");
Console.WriteLine(mat[mat.GetLength(0)-1,0]);
Console.WriteLine("Vrtice inferior derecho:");
Console.WriteLine(mat[mat.GetLength(0)-
1,mat.GetLength(1)-1]);
Console.ReadKey();
}
static void Main(string[] args)
{
Matriz8 ma = new Matriz8();
ma.Cargar();
ma.ImprimirVertices();
e tiene la siguiente informacin:
Nombres de 4 empleados.
Ingresos en concepto de sueldo, cobrado por cada empleado, en los ltimos 3
meses.
Confeccionar el programa para:
a) Realizar la carga de la informacin mencionada.
b) Generar un vector que contenga el ingreso acumulado en sueldos en los
ltimos 3 meses para cada empleado.
c) Mostrar por pantalla el total pagado en sueldos a todos los empleados en los
ltimos 3 meses
d) Obtener el nombre del empleado que tuvo el mayor ingreso acumulado

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

namespace Matriz9
{
class Matriz9
{
private string[] empleados;
private int[,] sueldos;
private int[] sueldostot;

public void Cargar()


{
empleados=new String[4];
sueldos=new int[4,3];
for(int f = 0; f < empleados.Length;
f++)
{
Console.Write("Ingrese el nombre
del empleado:");
empleados[f]=Console.ReadLine();
for(int c = 0; c <
sueldos.GetLength(1); c++)
{
Console.Write("Ingrese
sueldo:");
string linea;
linea = Console.ReadLine();

sueldos[f,c]=int.Parse(linea);
}
}
}

public void CalcularSumaSueldos()


{
sueldostot = new int[4];
for (int f = 0; f <
sueldos.GetLength(0); f++)
{
int suma = 0;
for (int c = 0; c <
sueldos.GetLength(1); c++)
{
suma = suma + sueldos[f,c];
}
sueldostot[f] = suma;
}
}

public void ImprimirTotalPagado()


{
Console.WriteLine("Total de sueldos
pagados por empleado.");
for(int f = 0; f <
sueldostot.Length; f++)
{
Console.WriteLine(empleados[f]+"
- "+sueldostot[f]);
}
}

public void EmpleadoMayorSueldo()


{
int may=sueldostot[0];
string nom=empleados[0];
for(int f = 0; f <
sueldostot.Length; f++)
{
if (sueldostot[f] > may)
{
may=sueldostot[f];
nom=empleados[f];
}
}
Console.WriteLine("El empleado con
mayor sueldo es "+ nom + " que tiene un sueldo
de "+may);
}

static void Main(string[] args)


{
Matriz9 ma = new Matriz9();
ma.Cargar();
ma.CalcularSumaSueldos();
ma.ImprimirTotalPagado();
ma.EmpleadoMayorSueldo();
Console.ReadKey();

1. Confeccionar una clase para administrar una matriz irregular de 5 filas y


1 columna la primer fila, 2 columnas la segunda fila y as sucesivamente
hasta 5 columnas la ltima fila (crearla sin la intervencin del operador)
Realizar la carga por teclado e imprimir posteriormente.
2. Confeccionar una clase para administrar los das que han faltado los 3
empleados de una empresa.
Definir un vector de 3 elementos de tipo string para cargar los nombres y
una matriz irregular para cargar los das que han faltado cada empleado
(cargar el nmero de da que falt)
Cada fila de la matriz representan los das de cada empleado.
Mostrar los empleados con la cantidad de inasistencias.
Cul empleado falt menos das.
3. using System;
4. using System.Collections.Generic;
5. using System.Linq;
6. using System.Text;
7.
8. namespace MatrizIrregular2
9. {
10. class MatrizIrregular2
11. {
12. private int[][] mat;
13.
14. public void Cargar()
15. {
16. mat=new int[5][];
17. for(int f = 0; f < mat.Length; f++)
18. {
19. mat[f]=new int[f+1];
20. for(int c = 0; c < mat[f].Length;
c++)
21. {
22. Console.Write("Ingrese
componente:");
23. string linea =
Console.ReadLine();
24. mat[f][c]=int.Parse(linea);
25. }
26. }
27. }
28.
29. public void Imprimir()
30. {
31. for(int f = 0; f < mat.Length; f++)
32. {
33. for(int c = 0; c < mat[f].Length;
c++)
34. {
35. Console.Write(mat[f][c]+" ");
36. }
37. Console.WriteLine();
38. }
39. Console.ReadKey();
40. }
41.
42. static void Main(string[] args)
43. {
44. MatrizIrregular2 ma = new
MatrizIrregular2();
45. ma.Cargar();
46. ma.Imprimir();
47. }
48. }
49. }
50.
51.
52.
53.
54. using System;
55. using System.Collections.Generic;
56. using System.Linq;
57. using System.Text;
58.
59. namespace MatrizIrregular3
60. {
61. class MatrizIrregular3
62. {
63. private string[] nombres;
64. private int[][] dias;
65.
66. public void Cargar()
67. {
68. nombres=new string[3];
69. dias=new int[3][];
70. for(int f = 0; f < nombres.Length; f++)
71. {
72. Console.Write("Ingrese el nombre del
empleado:");
73. nombres[f]=Console.ReadLine();
74. Console.Write("Cuantas das falt el
empleado:");
75. string linea = Console.ReadLine();
76. int faltas=int.Parse(linea);
77. dias[f]=new int[faltas];
78. for(int c = 0; c < dias[f].Length;
c++)
79. {
80. Console.Write("Ingrese nro de
da:");
81. linea = Console.ReadLine();
82. dias[f][c]=int.Parse(linea);
83. }
84. }
85. }
86.
87. public void Inasistencias()
88. {
89. for(int f = 0; f < nombres.Length; f++)
90. {
91. Console.WriteLine(nombres[f] + "
falt " + dias[f].Length + " das");
92. }
93. }
94.
95. public void EmpleadoMensosFaltas()
96. {
97. int faltas=dias[0].Length;
98. string nom=nombres[0];
99. for(int f = 1; f < dias.Length; f++)
100. {
101. if (dias[f].Length < faltas)
102. {
103. faltas=dias[f].Length;
104. nom=nombres[f];
105. }
106. }
107. Console.WriteLine("El empleado que
falt menos es "+nom+" con "+faltas+" faltas.");
108. Console.ReadKey();
109. }
110.
111. static void Main(string[] args)
112. {
113. MatrizIrregular3 ma = new
MatrizIrregular3();
114. ma.Cargar();
115. ma.Inasistencias();
116. ma.EmpleadoMensosFaltas();

Se desea guardar los sueldos de 5 operarios en un vector. Realizar la creacin y carga


del vector en el constructor.

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

namespace PruebaConstructor1
{
class Operarios
{
private int[] sueldos;

public Operarios()
{
sueldos=new int[5];
for(int f = 0; f < sueldos.Length;
f++)
{
Console.Write("Ingrese el
sueldo:");
string linea =
Console.ReadLine();
sueldos[f]=int.Parse(linea);
}
}

public void Imprimir()


{
for(int f = 0; f < sueldos.Length;
f++)
{
Console.WriteLine(sueldos[f]);
}
Console.ReadKey();
}

static void Main(string[] args)


{
Operarios op = new Operarios();
op.Imprimir();

Plantear una clase llamada Alumno y definir como atributos su nombre y su edad. En el
constructor realizar la carga de datos. Definir otros dos mtodos para imprimir los datos
ingresados y un mensaje si es mayor o no de edad (edad >=18)

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

namespace PruebaConstructor2
{
class Alumno
{
private string nombre;
private int edad;
public Alumno()
{
Console.Write("Ingrese nombre:");
nombre = Console.ReadLine();
Console.Write("Ingrese edad:");
string linea = Console.ReadLine();
edad=int.Parse(linea);
}

public void Imprimir()


{
Console.WriteLine("Nombre:"+nombre);
Console.WriteLine("Edad:"+edad);
}

public void EsMayorEdad()


{
if (edad >= 18)
{
Console.Write(nombre+" es mayor
de edad.");
}
else
{
Console.Write(nombre+" no es
mayor de edad.");
}
}

static void Main(string[] args)


{
Alumno alumno1 = new Alumno();
alumno1.Imprimir();
alumno1.EsMayorEdad();
Console.ReadKey();

Plantear tres clases A, B, C que B herede de A y C herede de B. Definir un constructor


a cada clase que muestre un mensaje. Luego definir un objeto de la clase C.

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

namespace Herencia3
{
public class A
{
public A()
{
Console.WriteLine("Constructor de la
clase A");
}
}

public class B : A
{
public B()
{
Console.WriteLine("Constructor de la
clase B");
}
}

public class C : B
{
public C()
{
Console.WriteLine("Constructor de la
clase C");
}
}

class Prueba
{
static void Main(string[] args)
{
C obj1 = new C();
Console.ReadKey();

También podría gustarte