• No se han encontrado resultados

INSTITUTO TECNOLÓGICO DE TIJUANA

N/A
N/A
Protected

Academic year: 2021

Share "INSTITUTO TECNOLÓGICO DE TIJUANA"

Copied!
30
0
0

Texto completo

(1)

SUBDIRECCIÓN ACADÉMICA

DEPARTAMENTO DE SISTEMAS Y COMPUTACIÓN

SEMESTRE AGOSTO-DICIEMBRE 2013

ING. EN SISTEMAS COMPUTACIONALES

FUNDAMENTOS DE PROGRAMACION 2SC1

Otros 1

UNIDAD 3

ALVAREZ LAPIZCO MIGUEL ANGEL

13211477

RODRIGUEZ MORENO MARCO ANTONIO

(2)

Indice

Introducción ... 1

Practica 1: Hola mundo! ... 2

Practica 2: Suma (2 + 3) ... 3

Practica 3: Suma de dos numeros ... 4

4. Nombre y edad ... 5

5. Area del circulo ... 6

6. Formula general ... 7

“” ... 8

7. Operaciones basicas ... 9

“” ... 10

8. Areas ... 11

“” ... 12

“” ... 13

9. Promedio de 6 calificaciones ... 14

10. Promedio (random) ... 15

11. Bebida (If) ... 16

12. Promedio (If) ... 17

“” ... 18

13. Numero mayor (If) ... 19

14. Numero menor (If) ... 20

15. Edad menor (If) ... 21

16. Edad (100 años) ... 22

17. MenuStrip ... 23

“ ... 24

“” ... 25

“” ... 26

“” ... 27

Conclusión ... 28

(3)

1

Introducción

En este proyecto comenzamos a aprender más detalladamente los

elementos que son base del C#, más adelante en este caso vemos lo que

es el “If” y comenzamos a aplicarla en práctica.

Vemos las prácticas cada vez más complejas conforme a lo que vamos

aprendiendo, estamos viendo la teoría y el uso práctico del “If” así como el

“MenusStrip” y otros elementos más simples como las variables usando Int,

Double, etc.

(4)

2

Practica 1: Hola mundo!

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programacion

* Matricula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void button2_Click(object sender, EventArgs e) {

MessageBox.Show("Hola mundo!"); }

private void button1_Click(object sender, EventArgs e) {

button4.Visible = false; }

private void button3_Click(object sender, EventArgs e) {

Close(); }

} }

(5)

3

Practica 2: Suma (2 + 3)

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programacion

* Matricula 13211477 * */

namespace WindowsFormsApplication2 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void button2_Click(object sender, EventArgs e) {

int suma; suma = 2 + 3;

MessageBox.Show("Tu resultado es: " + suma); }

private void button1_Click(object sender, EventArgs e) {

}

private void button3_Click(object sender, EventArgs e) {

Close(); }

} }

(6)

4

Practica 3: Suma de dos números.

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programacion

* Matricula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void button3_Click(object sender, EventArgs e) {

double a, b, res;

a = Convert.ToDouble(textBox1.Text); b = Convert.ToDouble(textBox2.Text); res = a + b;

MessageBox.Show("Tu resultado es : " + res); }

private void button4_Click(object sender, EventArgs e) {

Close(); }

private void button2_Click(object sender, EventArgs e) { button1.Visible = false; label4.Visible = false; textBox1.Clear(); textBox2.Clear(); } } }

(7)

5

Practica 4: Nombre y edad.

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programacion

* Matricula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void button2_Click(object sender, EventArgs e) {

string nombre;

nombre = textBox1.Text; int edad;

edad = Convert.ToInt16(textBox2.Text);

MessageBox.Show("Tu nombre es " + nombre + " y tienes " + edad + " años."); }

private void button4_Click(object sender, EventArgs e) {

Close(); }

private void button3_Click(object sender, EventArgs e) { textBox2.Clear(); textBox1.Clear(); } } }

(8)

6

Practica 5: Area de un circulo

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programacion

* Matricula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void button3_Click(object sender, EventArgs e) {

Close(); }

private void button2_Click(object sender, EventArgs e) {

double r, res;

r = Convert.ToDouble(textBox1.Text); res = (r * r) * 3.1416;

MessageBox.Show("Tu resultado es : " + res); }

private void button1_Click(object sender, EventArgs e) {

textBox1.Clear(); }

} }

(9)

7

Practica 6: Formula General.

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programacion

* Matricula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void Form1_Load(object sender, EventArgs e) {

}

private void button3_Click(object sender, EventArgs e) {

Close(); }

private void cal_Click(object sender, EventArgs e) {

Double a, b, c, res1, res2;

a = Convert.ToDouble(textBox1.Text); b = Convert.ToDouble(textBox2.Text); c = Convert.ToDouble(textBox3.Text);

res1 = (-b + (Math.Sqrt(Math.Pow(b, 2)) - (4 * a * c) ) / (2*a)); res2 = (-b - (Math.Sqrt(Math.Pow(b, 2)) - (4 * a * c) ) / (2*a));

(10)

8

MessageBox.Show("Tus resultados son : " + res1 + " y " + res2); }

private void lim_Click(object sender, EventArgs e) { textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); } } }

(11)

9

Practica 7: Operaciones basicas.

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programacion

* Matricula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void label2_Click(object sender, EventArgs e) {

}

private void Form1_Load(object sender, EventArgs e) {

}

private void cmddiv_Click(object sender, EventArgs e) {

int div, a, b;

a = Convert.ToInt32(textBox1.Text); b = Convert.ToInt32(textBox2.Text); div = a / b;

MessageBox.Show("Tu resultado es : " + div); }

private void cmdcal_Click(object sender, EventArgs e) {

(12)

10

textBox2.Clear(); label4.Text = " ";

}

private void cmdsalir_Click(object sender, EventArgs e) {

Close(); }

private void cmdsumar_Click(object sender, EventArgs e) {

int suma, a, b;

a = Convert.ToInt32(textBox1.Text); b = Convert.ToInt32(textBox2.Text); suma = a + b;

MessageBox.Show("Tu resultado es : " + suma); }

private void cmdrestar_Click(object sender, EventArgs e) {

int res, a, b;

a = Convert.ToInt32(textBox1.Text); b = Convert.ToInt32(textBox2.Text); res = a - b;

MessageBox.Show("Tu resultado es : " + res); }

private void cmdmulti_Click(object sender, EventArgs e) {

int multi, a, b;

a = Convert.ToInt32(textBox1.Text); b = Convert.ToInt32(textBox2.Text); multi = a * b;

MessageBox.Show("Tu resultado es : " + multi); }

private void textBox1_TextChanged(object sender, EventArgs e) {

}

private void pictureBox1_Click(object sender, EventArgs e) {

} } }

(13)

11

Practica 8: Areas.

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programacion

* Matricula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

(14)

12

}

private void button1_Click(object sender, EventArgs e) { label2.Visible = false; button2.Visible = false; button3.Visible = false; button4.Visible = false; label2.Visible = false; labelradio.Visible = true; txtradio.Visible = true; calcular.Visible = true; resultadocir.Visible = true; }

private void calcular_Click(object sender, EventArgs e) {

double r, res;

r = Convert.ToDouble(txtradio.Text); res = r * r * 3.1416;

MessageBox.Show("Tu resultado es : " + res); }

private void salir_Click(object sender, EventArgs e) {

Close(); }

private void button2_Click(object sender, EventArgs e) { label2.Visible = false; button1.Visible = false; button3.Visible = false; button4.Visible = false; txtalturatri.Visible = true; txtbasetri.Visible = true; basetri.Visible = true; alturatri.Visible = true; calculartri.Visible = true; resultadotri.Visible = true; }

private void calculartri_Click(object sender, EventArgs e) {

double a, b, res;

a = Convert.ToDouble(txtalturatri.Text); b = Convert.ToDouble(txtbasetri.Text); res = (a * b) / 2;

MessageBox.Show("Tu resultado es : " + res); }

private void regresar_Click(object sender, EventArgs e) {

(15)

13

private void Form1_Load(object sender, EventArgs e) {

} } }

(16)

14

Practica 9: Promedio de 6 calificaciones.

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programacion

* Matricula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { double a, b, c, d, Z, f, res; a = Convert.ToDouble(textBox1.Text); b = Convert.ToDouble(textBox2.Text); c = Convert.ToDouble(textBox3.Text); d = Convert.ToDouble(textBox4.Text); Z = Convert.ToDouble(textBox5.Text); f = Convert.ToDouble(textBox6.Text); res = (a + b + c + d + Z + f) / 6;

MessageBox.Show("Tu promedio es: " + res); textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); textBox6.Clear(); }

private void button2_Click(object sender, EventArgs e) {

Close(); }

} }

(17)

15

Practica 10: Promedio de calificaciones (random).

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programación

* Matrícula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) {

int c1, c2, c3, c4, c5, c6, prom; Random cal = new Random();

c1 = cal.Next(0, 100); c2 = cal.Next(0, 100); c3 = cal.Next(0, 100); c4 = cal.Next(0, 100); c5 = cal.Next(0, 100); c6 = cal.Next(0, 100); prom = (c1 + c2 + c3 + c4 + c5 + c6) / 6; textBox1.Text = c1.ToString(); textBox2.Text = c2.ToString(); textBox3.Text = c3.ToString(); textBox4.Text = c4.ToString(); textBox5.Text = c5.ToString(); textBox6.Text = c6.ToString();

MessageBox.Show("Tu promedio es : " + prom); }

private void button2_Click(object sender, EventArgs e) {

Close(); }

(18)

16

Practica 11: Bebida (if)

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programación

* Matrícula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void textBox1_TextChanged(object sender, EventArgs e) {

}

private void button1_Click(object sender, EventArgs e) {

if (textBox1.Text == "Coca-Cola") {

MessageBox.Show("Eres tripiante"); }

}

private void button2_Click(object sender, EventArgs e) {

Close(); }

} }

(19)

17

Practica 12: Promedio (If)

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programación

* Matrícula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void button2_Click(object sender, EventArgs e) { int c1, c2, c3, c4, c5, c6, prom; c1 = Convert.ToInt16(textBox1.Text); c2 = Convert.ToInt16(textBox2.Text); c3 = Convert.ToInt16(textBox3.Text); c4 = Convert.ToInt16(textBox4.Text); c5 = Convert.ToInt16(textBox5.Text); c6 = Convert.ToInt16(textBox6.Text); prom = (c1 + c2 + c3 + c4 + c5 + c6) / 6; if (prom >= 70)

MessageBox.Show("Tu calificación es APROVATORIA con un promedio de : " + prom);

}

private void button3_Click(object sender, EventArgs e) {

Close(); }

(20)

18

private void button1_Click(object sender, EventArgs e) { textBox1.Clear(); textBox2.Clear(); textBox3.Clear(); textBox4.Clear(); textBox5.Clear(); textBox6.Clear(); } } }

(21)

19

Practica 13: Numero mayor (If)

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programación

* Matrícula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { double a, b; a = Convert.ToDouble(textBox1.Text); b = Convert.ToDouble(textBox2.Text); if (a >= b) {

MessageBox.Show(a + " es mayor que" + " " + b); }

textBox1.Clear(); textBox2.Clear(); }

private void button2_Click(object sender, EventArgs e) {

}

private void button3_Click(object sender, EventArgs e) {

Close(); }

} }

(22)

20

Practica 14: Numero menor

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programación

* Matrícula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) { { double a, b; a = Convert.ToDouble(textBox1.Text); b = Convert.ToDouble(textBox2.Text); if (a <= b) {

MessageBox.Show(a + " es menor que" + " " + b); }

textBox1.Clear(); textBox2.Clear(); }

}

private void button3_Click(object sender, EventArgs e) {

Close(); }

} }

(23)

21

Practica 15: Edad es menor (If)

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programación

* Matrícula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void button3_Click(object sender, EventArgs e) {

Close(); }

private void button2_Click(object sender, EventArgs e) {

textBox1.Clear(); }

private void button1_Click(object sender, EventArgs e) {

int a;

a = Convert.ToInt16(textBox1.Text); if (a <= 18)

MessageBox.Show("Eres menor de edad por " + (18 - a)+ " años"); }

} }

(24)

22

Practica 16: Edad (100 años)

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programación

* Matrícula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

public Form1() {

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) {

int a;

a = Convert.ToInt16(textBox1.Text); if (a >= 100)

MessageBox.Show("Ya estas viejo compa"); }

private void button2_Click(object sender, EventArgs e) {

Close(); }

} }

(25)

23

(26)

24

Forma 1 (código)

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programación

* Matrícula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form1 : Form

{

(27)

25

{

InitializeComponent(); }

private void mensajeToolStripMenuItem_Click(object sender, EventArgs e) {

}

private void salirToolStripMenuItem_Click(object sender, EventArgs e) {

Close(); }

private void mensajeToolStripMenuItem1_Click(object sender, EventArgs e) {

Form mensaje = new Form3(); mensaje.Show();

}

private void sumaToolStripMenuItem1_Click(object sender, EventArgs e) {

Form op = new Form2(); op.Show();

this.Hide(); }

private void restaToolStripMenuItem_Click(object sender, EventArgs e) { label1.Visible = true; label2.Visible = true; button1.Visible = true; button2.Visible = true; button3.Visible = true; button4.Visible = true; textBox1.Visible = true; textBox2.Visible = true; }

private void button1_Click(object sender, EventArgs e) {

double a, b, res;

a = Convert.ToDouble(textBox1.Text); b = Convert.ToDouble(textBox2.Text); res = a - b;

MessageBox.Show("Tu resultado es : " + res); }

private void button2_Click(object sender, EventArgs e) {

textBox1.Clear(); textBox2.Clear(); }

private void button4_Click(object sender, EventArgs e) {

(28)

26

label1.Visible = false; label2.Visible = false; button1.Visible = false; button2.Visible = false; button3.Visible = false; button4.Visible = false; textBox1.Visible = false; textBox2.Visible = false; }

private void button3_Click(object sender, EventArgs e) { Close(); } } }

Forma 2 (código)

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programación

* Matrícula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form2 : Form

{

public Form2() {

InitializeComponent(); }

private void button1_Click(object sender, EventArgs e) {

double a, b, res;

a = Convert.ToDouble(textBox1.Text); b = Convert.ToDouble(textBox2.Text); res = a + b;

MessageBox.Show("Tu resultado es : " + res); }

private void button5_Click(object sender, EventArgs e) {

}

private void button3_Click(object sender, EventArgs e) {

textBox1.Clear(); textBox2.Clear(); }

(29)

27

{

Form menu = new Form1(); menu.Show();

this.Hide(); }

private void button4_Click(object sender, EventArgs e) { Close(); } } }

Forma 3 (código)

/* Alvarez Lapizco Miguel Angel

* Ingenieria en Sistemas Computacionales * Fundamentos de Programación

* Matrícula 13211477 * */

namespace WindowsFormsApplication1 {

public partial class Form3 : Form

{

public Form3() {

InitializeComponent(); }

private void button2_Click(object sender, EventArgs e) {

this.Hide(); }

private void button1_Click(object sender, EventArgs e) {

MessageBox.Show("Hola salón 502!"); }

private void button3_Click(object sender, EventArgs e) {

Close(); }

} }

(30)

28

Conclusión

Puedo decir que estas practicas han sido de gran uso para mi, es muy importante adquirir

conocimientos como este de programación para comenzar a crear aplicaciones cada vez mas

complejas. Poco a poco nosotros estamos avanzando en nuestra carrera y cada dia creamos

programas mas complejas y esto si es muy agradable para mi ya que por fin ya estamos

programando algo bien en vez de estar aprendiendo y estudiando teoría como siempre. Espero

poder aprender lo que es el C# y el Java a lo mas que se pueda.

Referencias

Documento similar

Volviendo a la jurisprudencia del Tribunal de Justicia, conviene recor- dar que, con el tiempo, este órgano se vio en la necesidad de determinar si los actos de los Estados

Como asunto menor, puede recomendarse que los órganos de participación social autonómicos se utilicen como un excelente cam- po de experiencias para innovar en materia de cauces

Sin embargo, mientras que la primera de tales actividades tiene lugar necesariamente siempre que exista una petición de referéndum, las otras dos no se llevan a cabo en todo caso,

Tras establecer un programa de trabajo (en el que se fijaban pre- visiones para las reuniones que se pretendían celebrar los posteriores 10 de julio —actual papel de los

Por PEDRO A. EUROPEIZACIÓN DEL DERECHO PRIVADO. Re- laciones entre el Derecho privado y el ordenamiento comunitario. Ca- racterización del Derecho privado comunitario. A) Mecanismos

Cualquier Estado ha nacido siempre en torno a un núcleo ori- ginario que a veces no es otra cosa que la Administración del Estado anterior, que en cierto modo supervive, y otras

b) El Tribunal Constitucional se encuadra dentro de una organiza- ción jurídico constitucional que asume la supremacía de los dere- chos fundamentales y que reconoce la separación

Esta noción será una herramienta fundaniental para manejar la geometría de la curva r(= aQ), que a su vez será clave en la solución del problema de funciones conformes