0% found this document useful (0 votes)
135 views6 pages

#Include Main (Int A, B, Suma Cout A Cout B Suma A+b Cout "/N La Suma de " A "+" B " Es:" Suma Return 0 )

The document contains code examples in multiple programming languages (C++, VB.NET, Java) that convert numeric values to Roman numerals. The code divides the numeric value into individual digits and uses conditionals and arrays to map each digit to the corresponding Roman numeral character or characters.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
135 views6 pages

#Include Main (Int A, B, Suma Cout A Cout B Suma A+b Cout "/N La Suma de " A "+" B " Es:" Suma Return 0 )

The document contains code examples in multiple programming languages (C++, VB.NET, Java) that convert numeric values to Roman numerals. The code divides the numeric value into individual digits and uses conditionals and arrays to map each digit to the corresponding Roman numeral character or characters.
Copyright
© Attribution Non-Commercial (BY-NC)
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

view plainprint?

1. Public Class Form1 2. Private Sub Button1_Click(ByVal sender As System.Object, 3. ByVal e As System.EventArgs) Handles Button1.Click 4. Dim a, b, suma As Double 5. a = TextBox1.Text 6. b = TextBox2.Text 7. suma = a + b 8. TextBox3.Text = Trim(suma) 9. End Sub 10. End Class

C++
#include <iostream.h> main() {int a,b,suma; cout<<"\n ingrese numero a:"; cin>>a; cout<<"\n ingrese numero b:"; cin>>b; suma=a+b; cout<<"\n la suma de "<<a<<"+"<<b<<" es:"<<suma; return 0; }

netbeans
public class ClaseConvertir { public String convertirRomano(int num) { String romano = ""; int[] numeros = {1000, 500, 100, 50, 10, 5, 1};

String[] letras = {"M", "D", "C", "L", "X", "V", "I"}; for (int i = 0; num >= 1; i++) { int x = num / numeros[i]; if (x < 4) { for (int j = 0; j < x; j++) { romano += letras[i]; } } else { for (int j = 0; j < 5 - x; j++) { romano += letras[i]; } romano += letras[i - 1]; } num -= x * numeros[i]; } return romano; } }

C++
#include <cstdlib> #include <iostream> using namespace std; int main(int argc, char *argv[]) {

int x,a,b,c,d,e,f; cout<<"Ingrese un numero entre 1000 a 2000"<<endl; cin>>x; a=x/1000; b=x%1000; c=b/100; d=b%100; e=d/10; f=d%10; if(x>=1000 && x<=2000) { switch(a) { case 1: cout<<"M"; break;

} switch(c) { case 1: cout<<"C"; break; case 2: cout<<"CC"; break; case 3: cout<<"CCC"; break; case 4: cout<<"CD"; break; case 5: cout<<"D"; break; case 6: cout<<"DC"; break; case 7: cout<<"DCC"; break; case 8: cout<<"DCCC"; break; case 9: cout<<"CM"; break; } switch(e) { case 1: cout<<"X"; break; case 2: cout<<"XX"; break; case 3: cout<<"XXX"; break; case 4: cout<<"XL"; break; case 5: cout<<"L"; break; case 6: cout<<"LX"; break;

case 7: cout<<"LXX"; break; case 8: cout<<"LXXX"; break; case 9: cout<<"XC"; } switch (f) { case 1: cout<<"I"; break; case 2: cout<<"II"; break; case 3: cout<<"III"; break; case 4: cout<<"IV"; break; case 5: cout<<"V"; break; case 6: cout<<"VI"; break; case 7: cout<<"VII"; break; case 8: cout<<"VIII"; break; case 9: cout<<"IX"; break; } }

system("PAUSE"); return EXIT_SUCCESS; }

C++

#include <stdio.h> #include <stdlib.h> int main() { int num,entero,res; printf( "Introduce un numero " ); scanf( "%i", &num ); /* Dividimos por 100 */ entero = num/100; res = num%100; switch( entero ) { case 1: printf( "C" ); break; case 2: printf( "CC" ); break; case 3: printf( "CCC" ); break; case 4: printf( "CD" ); break; case 5: printf( "D" ); break; case 6: printf( "DC" ); break; case 7: printf( "DCC" ); break; case 8: printf( "DCCC" ); break; case 9: printf( "CM" ); break; } /*Dividimos por 10 */ entero = res/10; res=res%10; switch( entero ) { case 1: printf( "X" ); break; case 2: printf( "XX" ); break; case 3: printf( "XXX" ); break; case 4: printf( "XL" ); break; case 5: printf( "L" ); break; case 6: printf( "LX" ); break; case 7: printf( "LXX" ); break; case 8: printf( "LXXX" ); break; case 9: printf( "XC" ); break; } switch( res ) {

case 1: printf( "I" ); break; case 2: printf( "II" ); break; case 3: printf( "III" ); break; case 4: printf( "IV" ); break; case 5: printf( "V" ); break; case 6: printf( "VI" ); break; case 7: printf( "VII" ); break; case 8: printf( "VIII" ); break; case 9: printf( "IX" ); break; } printf("n"; system("pause"; }

1. import java.util.Scanner; 2. public class Main { 3. public static void main(String[] args) { 4. Scanner sc=new Scanner(System.in); 5. String Unidad[]={"", "I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX"}; 6. String Decena[]={"", "X", "XX", "XXX", "XL", "L", "LX", "LXX", "LXXX", " XC"}; 7. String Centena[]={"", "C", "CC", "CCC", "CD", "D", "DC", "DCC", "DCCC", " CM"}; 8. String Mil[]={"", "M", "MM"}; 9. System.out.println("Ingresa numero entre 1000 y 2000"); 10. int N = sc.nextInt(); 11. int u=N%10; 12. int d=(N/10)%10; 13. int c=(N/100)%10; 14. int m=N/1000; 15. if(N>=1000 && N<=2000){ 16. System.out.println(Mil[m]+Centena[c]+Decena[d]+Unidad[u]); 17. }else{ 18. System.out.println("Fuera de Rango"); 19. } 20. } 21. }

You might also like