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
        public Form1()

        private void btnRom_Click(object sender, EventArgs e)

            string[] Roman = { "M", "CM", "D", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" };
            int[] Arabic = {1000,900,500,400,100,90,50,40,10,9,5,4,1};
            int Input;
        // Numeric representation of the input field.
            int intTemp;
        // Used to store the magnitude of each decimal digit.
            short Pointer = 0;
        // Pointer to the Roman and Decimal arrays, starts at the first cell.
            short CountI;
        // Temporary variable used for loops.
            Input = Convert.ToInt32(this.txtRom.Text);
        // Convert the string in the input field to an integer.
        // Clear the contents of the output field.
        // Check to see if Input still has any value left in it.
            while (Input > 0)

                intTemp = Input / Arabic[Pointer];
    // See how many of the currently selected value can fit in the remaining input.
            for (CountI = 1; CountI <= intTemp; CountI++) 
                 txtAra.Text += Roman[Pointer];
        // Append a number of Roman Characters depending on the value of intTemp.

        Input -= intTemp * Arabic[Pointer];
// Subtract the value of the characters that were appended to output from the input.
Pointer += 1;
        // Move the pointer to the next cell of the arrays.}


        private void btnAra_Click(object sender, EventArgs e)
            int[] Values = new int[101];
            // Reserve space for an array.
            int intLoopI;
            // Initialize the loop counter to 0.
            int intTotal;
            // Clear the total.
            int PreviousPointer = 0;
            // Set the value of the previous pointer to some MIN value.
            int CurrentPointer;
            // This will hold the value of the current Roman Numeral character.
            Values("M") = 1000;
            Values("D") = 500;
            Values("C") = 100;
            Values("L") = 50;
            Values("X") = 10;
            Values("V") = 5;
            Values("I") = 1;
            // Assume 1 indexing
            for (intLoopI = (this.txtRom.Text); intLoopI >= 1; intLoopI += -1)
              CurrentPointer = Values((this.txtRom.Text, intLoopI, 1).ToUpper());
                // the value of the pointer will be the values of the letters 
                // in the Roman numeral text box and initialize the loop also makes the letter uppercase

                // if the value of the current pointer or Letter is greater than the 
                if (CurrentPointer < PreviousPointer)
                    intTotal = intTotal - CurrentPointer;
                    // letter after it then subtract the two but if thats not the case add both
                else { intTotal = intTotal + CurrentPointer; }

                PreviousPointer = CurrentPointer;

            this.txtAra.Text = Conversion.Str(intTotal);



Recommended Answers

why? No one in his/her right mind would want to manually convert that to assembly.

Jump to Post

All 2 Replies

why? No one in his/her right mind would want to manually convert that to assembly.

why? No one in his/her right mind would want to manually convert that to assembly.

i do have a prog in s c# but i cant do it in asm

Be a part of the DaniWeb community

We're a friendly, industry-focused community of 1.21 million developers, IT pros, digital marketers, and technology enthusiasts learning and sharing knowledge.