1. INICIO
radio = altura = volumen = area = 0;
PRINT("Introduce el valor del radio: ");
READ radio
PRINT("Introduce el valor del altura: ");
READ altura
volumen = (3.14 * radio * radio * altura);
area = (2*3.14*radio*(altura+radio));
PRINT("El volumen es igual a: {0}" , volumen);
PRINT("El area es igual a: {0}", area);
FINAL
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double radio, altura, volumen, area;
radio = altura = volumen = area = 0;
Console.WriteLine("Introduce el valor del radio: ");
radio = double.Parse(Console.ReadLine());
Console.WriteLine("Introduce el valor del altura: ");
altura = double.Parse(Console.ReadLine());
volumen = (3.14 * radio * radio * altura);
area = (2*3.14*radio*(altura+radio));
Console.WriteLine("El volumen es igual a: {0}" , volumen);
Console.WriteLine("El area es igual a: {0}", area);
Console.ReadKey();
}
}
}
PRACTICA 3 AREA DE UN TRIANGULO (A. VISUAL)
using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
double radio, altura, volumen, area;
public Form1()
{
InitializeComponent();
radio = altura = volumen = area = 0;
}
private void label2_Click(object sender, EventArgs e)
{
}
private void button1_Click(object sender, EventArgs e)
{
radio = double.Parse(textBox1.Text);
altura = double.Parse(textBox2.Text);
volumen = (3.14 * radio * radio * altura);
area = (2 * 3.14 * radio * (altura + radio));
textBox3.Text=("")+volumen.ToString();
textBox4.Text=("")+area.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
Close();
}
private void pictureBox1_Click(object sender, EventArgs e)
{
}
private void button3_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
}
}
}
PRACTICA 3 Area de un triangulo (B. CONSOLA)
1. INICIO
double P, Area, A, B, C;
PRINT("Introduce las tres longitudes de un triangulo");
READ A
READ B
READ C
P = (A + B + C) / 2;
Area = Math.Sqrt(P * (P - A) * (P - B) * (P - C));
PRINT("El area del triangulo es: {0}", Area);
FIN
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double P, Area, A, B, C;
Console.WriteLine("Introduce las tres longitudes de un triangulo");
A = double.Parse(Console.ReadLine());
B = double.Parse(Console.ReadLine());
C = double.Parse(Console.ReadLine());
P = (A + B + C) / 2;
Area = Math.Sqrt(P * (P - A) * (P - B) * (P - C));
Console.WriteLine("El area del triangulo es: {0}", Area);
Console.ReadKey();
}
}
}
PRACTICA 3 Area de un triangulo (B. VISUAL)
using System;using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
double P, Area, A, B, C;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
A = double.Parse(textBox1.Text);
B = double.Parse(textBox2.Text);
C = double.Parse(textBox3.Text);
P = (A + B + C) / 2;
Area = Math.Sqrt(P * (P - A) * (P - B) * (P - C));
textBox4.Text = (" ") + Area.ToString();
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
textBox4.Clear();
}
private void button3_Click(object sender, EventArgs e)
{
Close();
}
}
}
PRACTICA 3 ALMACEN (C. CONSOLA)
1. INICIO
int codigo,cant, precio, total, descuento, pago;
PRINT("introduce codigo");
READ codigo
PRINT("introduce la cantidad");
READ cant
PRINT("introduce el precio");
READ precio
if (cant > 100)
{
PRINT("descuento 40%");
total = cant * precio;
descuento = (total * 40) / 100;
pago = total - descuento;
}
else
{
if (cant > 24)
{
PRINT("descuento 20%");
total = cant * precio;
descuento = (total * 20) / 100;
pago = total - descuento;
}
else
{
if (cant > 9)
{
PRINT("descuento 10%");
total = cant * precio;
descuento = (total * 10) / 100;
pago = total - descuento;
}
else
{
PRINT("no hay descuento");
total = cant * precio;
descuento = 0;
pago = total - descuento;
}
}
}
PRINT("el total es:{0}", total);
PRINT("el precio final es{0}",pago);
FIN
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
int codigo,cant, precio, total, descuento, pago;
Console.WriteLine("introduce codigo");
codigo = int.Parse(Console.ReadLine());
Console.WriteLine("introduce la cantidad");
cant = int.Parse(Console.ReadLine());
Console.WriteLine("introduce el precio");
precio = int.Parse(Console.ReadLine());
if (cant > 100)
{
Console.WriteLine("descuento 40%");
total = cant * precio;
descuento = (total * 40) / 100;
pago = total - descuento;
}
else
{
if (cant > 24)
{
Console.WriteLine("descuento 20%");
total = cant * precio;
descuento = (total * 20) / 100;
pago = total - descuento;
}
else
{
if (cant > 9)
{
Console.WriteLine("descuento 10%");
total = cant * precio;
descuento = (total * 10) / 100;
pago = total - descuento;
}
else
{
Console.WriteLine("no hay descuento");
total = cant * precio;
descuento = 0;
pago = total - descuento;
}
}
}
Console.WriteLine("el total es:{0}", total);
Console.WriteLine("el precio final es{0}",pago);
Console.ReadKey();
}
}
}
PRACTICA 3 (C. VISUAL)
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
int cant,precio,total,descuento,pago;
public Form1()
{
cant = precio = total = descuento = pago = 0;
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
}
private void textBox2_TextChanged(object sender, EventArgs e)
{
}
private void bxTotal_TextChanged(object sender, EventArgs e)
{
}
private void Calcular_Click(object sender, EventArgs e)
{
cant = int.Parse(bxcant.Text);
precio = int.Parse(bx.Text);
total = cant * precio;
bxTotal.Text = total.ToString();
if (cant > 100)
{
descuento = (total * 40) / 100;
bxDescuento.Text =descuento.ToString();
pago = total - descuento;
bxPago.Text = pago.ToString();
}
else
if (cant > 24)
{
descuento = (total * 20) / 100;
bxDescuento.Text =descuento.ToString();
pago = total - descuento;
bxPago.Text = pago.ToString();
}
else
if (cant > 9)
{
descuento = (total * 10) / 100;
bxDescuento.Text = descuento.ToString();
pago = total - descuento;
bxPago.Text = pago.ToString();
}
else
descuento = 0;
bxDescuento.Text = descuento.ToString();
pago = total - descuento;
bxPago.Text = pago.ToString();
}
private void Limpiar_Click(object sender, EventArgs e)
{
bx.Clear();
bxcant.Clear();
bxDescuento.Clear();
bxPago.Clear();
bxTotal.Clear();
}
private void Salir_Click(object sender, EventArgs e)
{
Close();
}
}
}
PRACTICA 3 CELCIUS Y FAHRENHEIT (D. CONSOLA)
1. INICIO
double t, f, c;
string g;
PRINT ("Introduce el valor de la temperatura:");
READ t
PRINT ("Introduce grados fahrenheit (f°) o grados celcius (c°):");
READ g
if (g=="f" || g=="F")
{
c = (5.0 / 9.0) * (t - 32.0);
PRINT ("La temperatura de " + t + " f° es igual a " + c + " c° ", t, c);
}
if (g=="c" || g=="C")
{
f = (9.0/5.0)*t + 32.0;
PRINT ("La temperatura de " + t + " c° es igual a " + f + " f° ", t, f);
}
if (g != "c" || g != "f" && g != "C" || g != "F")
{
PRINT ("El factor de conversion no es correcto");
FIN
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace ConsoleApplication1
{
class Program
{
static void Main(string[] args)
{
double t, f, c;
string g;
Console.Write("Introduce el valor de la temperatura:");
t = double.Parse(Console.ReadLine());
Console.Write("Introduce grados fahrenheit (f°) o grados celcius (c°):");
g = Console.ReadLine();
if (g=="f" || g=="F")
{
c = (5.0 / 9.0) * (t - 32.0);
Console.WriteLine("La temperatura de " + t + " f° es igual a " + c + " c° ", t, c);
Console.ReadLine();
}
if (g=="c" || g=="C")
{
f = (9.0/5.0)*t + 32.0;
Console.WriteLine("La temperatura de " + t + " c° es igual a " + f + " f° ", t, f);
Console.ReadLine();
}
if (g != "c" || g != "f" && g != "C" || g != "F")
{
Console.Write("El factor de conversion no es correcto");
Console.ReadKey();
}
}
}
}
PRACTICA 3CELCIUS Y FAHRENHEIT (D. VISUAL)
using System.Collections.Generic;using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
namespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
double t, f, c;
string g;
public Form1()
{
InitializeComponent();
t = f = c = 0;
g = " ";
}
private void button1_Click(object sender, EventArgs e)
{
t = double.Parse(textBox1.Text);
g = textBox2.Text;
if (g == "f" || g == "F")
{
c = (5.0 / 9.0) * (t - 32.0);
textBox3.Text = c.ToString();
}
else
{
if (g == "c" || g == "C")
{
f = (9.0 / 5.0) * t + 32.0;
textBox3.Text = f.ToString();
}
else
{
if (g != "c" || g != "f" || g != "C" || g != "F")
{
textBox3.Text = "Presiono opcion equivocada";
}
}
}
}
private void button2_Click(object sender, EventArgs e)
{
textBox1.Clear();
textBox2.Clear();
textBox3.Clear();
}
}
}
No hay comentarios:
Publicar un comentario