using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace NumerosRomanos_Forms
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
int numeroentrada;
private void button2_Click(object sender, EventArgs e)
{
Application.Exit();
}
private void button1_Click(object sender, EventArgs e)
{
int Miles, Centenas, Decenas, Unidades, RestoMiles, RestoCentenas, RestoDecenas, N;
N = numeroentrada;
Miles = N / 1000;
RestoMiles = N % 1000;
Centenas = RestoMiles / 100;
RestoCentenas = RestoMiles % 100;
Decenas = RestoCentenas / 10;
RestoDecenas = RestoCentenas % 10;
Unidades = RestoDecenas;
switch (Miles)
{
case 1: textBox2.Text += "M"; break;
case 2: textBox2.Text += "MM"; break;
case 3: textBox2.Text += "MMM"; break;
}
switch (Centenas)
{
case 1: textBox2.Text += "C"; break;
case 2: textBox2.Text += "CC"; break;
case 3: textBox2.Text += "CCC"; break;
case 4: textBox2.Text += "CD"; break;
case 5: textBox2.Text += "D"; break;
case 6: textBox2.Text += "DC"; break;
case 7: textBox2.Text += "DCC"; break;
case 8: textBox2.Text += "DCCC"; break;
case 9: textBox2.Text += "CM"; break;
}
switch (Decenas)
{
case 1:
textBox2.Text += "X";
break;
case 2:
textBox2.Text += "XX";
break;
case 3:
textBox2.Text += "XXX";
break;
case 4:
textBox2.Text += "XL";
break;
case 5:
textBox2.Text += "L";
break;
case 6:
textBox2.Text += "LX";
break;
case 7:
textBox2.Text += "LXX";
break;
case 8:
textBox2.Text += "LXXX";
break;
case 9:
textBox2.Text += "XC";
break;
}
switch (Unidades)
{
case 1:
textBox2.Text += "I"; break;
case 2:
textBox2.Text += "II"; break;
case 3:
textBox2.Text += "III"; break;
case 4:
textBox2.Text += "IV"; break;
case 5:
textBox2.Text += "V"; break;
case 6:
textBox2.Text += "VI"; break;
case 7:
textBox2.Text += "VII"; break;
case 8:
textBox2.Text += "VIII"; break;
case 9:
textBox2.Text += "IX"; break;
}
}
private void textBox1_TextChanged(object sender, EventArgs e)
{
numeroentrada = int.Parse(textBox1.Text);
}
}
}
No hay comentarios:
Publicar un comentario
Nota: solo los miembros de este blog pueden publicar comentarios.