double opcion, x, y, o;
double ("Seleccione una operacion a realizar de la siguiente");
double ("1.-Sumar");
double ("2.-Resta");
double ("3.-Multiplicacion");
double ("4.-Division");
Read opcion
double ("Introdusca dato 1");
Read x
double ("Introdusca dato 2");
Read y
if (opcion == 1)
{
o = x + y;
double (" EL resultado en suma es :{0}", o);
}
else if (opcion == 2)
{
o = x - y;
double (" EL resultado en suma es :{0}", o);
}
else if (opcion == 3)
{
o = x * y;
double (" EL resultado en suma es :{0}", o);
}
else if (opcion == 4)
{
if (y == 0)
{
double ("error introduce un numero mayor a 0");
}
else if (y > 0)
{
o = x / y;
double(" EL resultado en suma es :{0}", o);
FIN
using System; using System.Collections.Generic; using System.Linq; using System.Text;
namespace ConsoleApplication1 { class Program { double opcion, x, y, o; static void Main(string[] args) { double opcion, x, y, o; Console.WriteLine("Seleccione una operacion a realizar de la siguiente"); Console.WriteLine("1.-Sumar"); Console.WriteLine("2.-Resta"); Console.WriteLine("3.-Multiplicacion"); Console.WriteLine("4.-Division"); opcion = double.Parse(Console.ReadLine()); Console.WriteLine("Introdusca dato 1"); x = double.Parse(Console.ReadLine()); Console.WriteLine("Introdusca dato 2"); y = double.Parse(Console.ReadLine());
if (opcion == 1) { o = x + y; Console.WriteLine(" EL resultado en suma es :{0}", o); Console.ReadLine();
}
else if (opcion == 2) { o = x - y; Console.WriteLine(" EL resultado en suma es :{0}", o); Console.ReadLine();
} else if (opcion == 3) { o = x * y; Console.WriteLine(" EL resultado en suma es :{0}", o); Console.ReadLine();
} else if (opcion == 4) { if (y == 0) { Console.WriteLine("error introduce un numero mayor a 0"); Console.ReadLine(); } else if (y > 0) { o = x / y; Console.WriteLine(" EL resultado en suma es :{0}", o); Console.ReadLine(); }
} } } }
PRACTICA 4 (B. visual)
amespace WindowsFormsApplication1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
double radio, altura, volumen, area; 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; 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(); } } }
PRACTICA3 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;
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; 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();
} } }
PRACTICA3 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(); }
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; 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(); } } }
PRACTICA3 (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(); }
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; 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(); } } }
}
PRACTICA3CELCIUS 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") {