![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiteJHdCYvLtyAn6umJd7Ghq4fJAKcJNtjulJgMn6LxJcbMtibYgKq3h_Od-XP_SX9pv-bIftWqkFfYepVbMVpQnZ1HJNjLEyZBoTlT4bh6bweDfx01xesSXceUxjSPn2UKHD6ErLjrqZur/s400/diagrama+de+flujo.jpg)
Thursday, September 25, 2008
Practica 2 VISUAL
![](https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEh2i0f2Ua_ssg5Ai9wU64yBDRr3Sn3gk1oBH7mAXqUOG2kJb4R_aItt8VZ2jlx_Voov4WkGFjRo89PQCWDLeGBYuYjrP_BNeq3DWlkspmCHXk79HAo25Cf64YiQ0TGbQcuxiAYCbQWQ2yaE/s400/PRACTICA+2.jpg)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
namespace practica_2_visual
{
public partial class frmpractica2visual : Form
{
public frmpractica2visual()
{
InitializeComponent();
}
double[] corriente = new double[10];
double[] resistencia = new double[10] { 26, 40, 44, 50, 66, 89, 10, 32, 5, 18 };
double[] potencia = new double[10];
int i = 0;
double total = 0;
private void cmdcorriente_Click(object sender, EventArgs e)
{ //DIAZ CABALLERO JOSE SALVADOR
//PROGRAMACION ORIENTADA A OBJETOS
//PROFESORA COLUNGA
// PRACTICA 2
//asigancion de valores a variables
corriente[i]= double.Parse(txtcorriente.Text);
lstcorriente.Items.Add(corriente[i].ToString());
txtcorriente.Clear();
txtcorriente.Focus();
i++;
// condicion para cuando termine el ciclo de capturar, cacula potencia y total y aguega a las listas datos
if ( i ==10){
txtcorriente.Enabled=false;
cmdcorriente.Enabled=false;
for( i=0; i<10; i++){
potencia[i]= resistencia[i] * (Math.Pow(corriente[i] , 2));
total=total+ potencia[i];
lstpotencia.Items.Add(potencia[i].ToString());
lstresistencia.Items.Add(resistencia[i].ToString());
}
lblTotal.Text= "el total es: "+ total.ToString();
}
}
private void cmdLimpiar_Click(object sender, EventArgs e)
{
cmdcorriente.Enabled = true;
txtcorriente.Enabled = true;
lstresistencia.Items.Clear();
lstcorriente.Items.Clear();
lstpotencia.Items.Clear();
txtcorriente.Focus();
lblTotal.Text = "";
}
private void cmdSalir_Click(object sender, EventArgs e)
{
Close();
}
}
}
Practica 2
Escriba un programa que almacene los siguientes valores en un arreglo llamado resistencia: 26,40,44,50,66,89,10,32,5,18 .El programa debe crear dos arreglos llamados corriente y potencia, los cuales deberán ser capaces de almacenar diez numeros de doble precision. Emplendo una gaza for y una instruccion de entrada de datos por el teclado, haga que el programa acepte diez números introducidos por el usuario en el arreglo corriente al ejecutar el programa, el cual debe almacenar en el arreglo potencia el producto de los valores correspondiente al cuadrado del arreglo corriente y del arreglo resistencia ( por ejemplo, potencia[i]=resistencia[i]* Math.Pow(corriente[i],2) y desplegar la siguiente salida:Resistencia Corriente Potencia
using System;
using System.Collections.Generic;
using System.Text;
namespace practica2
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("el shaviux production.......... present");
int i;
double total = 0;
double[]corriente = new double[10];
double[] resistencia = new double[10] { 26, 40, 44, 50, 66, 89, 10, 32, 5, 18 };
double [] potencia = new double[10];
for (i = 0; i < 10; i++)
{
Console.Write(" \n Corriente {0} ", i + 1);
corriente[i] = double.Parse(Console.ReadLine());
potencia[i] = resistencia[i] * corriente[i];
total = total + potencia[i];
}
Console.WriteLine("\n\n Corriente Resistencia Potencia ");
for (i = 0; i < 10; i++)
{
Console.WriteLine("{0,6} {1,14} {2,10}", corriente[i], resistencia[i], potencia[i]);
}
Console.WriteLine("el total es:"+ total);
Console.WriteLine("Dar INTRO para salir");
Console.ReadLine();
}
}
}
PRACTICA 1
Escriba un programa para introducir N numeros enteros en un arreglo llamado emax y encuentre el máximo valor introducido. El programa debe contener sólo una gaza y el máximo,minimo y diferencia, debe determinarse al introducir los valores de los elementos del arreglo
using System;
using System.Collections.Generic;
using System.Text;
namespace practica1
{
class Program
{
static void Main(string[] args)
{
{
int N, mayor = 0, menor = 99999999, diferencia=0;
Console.Write("Introduce la cantidad de valores enteros : ");
N = int.Parse(Console.ReadLine());
int[] emax = new int[N];
int i;
Console.WriteLine(" introduzca los {0} valores enteros ", N);
for (i = 0; i < N; i++)
{
Console.Write(" dato {0} : ", i + 1);
emax[i] = int.Parse(Console.ReadLine());
if (emax[i] > mayor)
{
mayor = emax[i];
}
if (emax[i] < menor)
{
menor = emax[i];
}
diferencia=mayor-menor;
}
Console.WriteLine("El dato mayor es : {0}", mayor);
Console.ReadLine();
Console.WriteLine("El dato menor es: {0}", menor);
Console.ReadLine();
Console.WriteLine("La diferencia del mayor al menor es de: {0}", diferencia);
Console.ReadLine();
}
}
}
}