Roman numerals

Assignment: Write a program that accepts a year written as a four digit Arabic (normal) numeral and outputs the year written in Roman numerals. Important Roman numerals are: V for 5, X for 10, L for 50, C for 100, D for 500, and M for 1000.

Please provide the code. Thanks!
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Program Roman;

var year, mag : integer;
var roman     : string;

  function get_roman (digit, magnitude : integer) : string;
  var one, five, ten : string;
    case magnitude of
      1:    begin  one := 'I'; five := 'V';   ten := 'X';  end;
      10:   begin  one := 'X'; five := 'L';   ten := 'C';  end;
      100:  begin  one := 'C'; five := 'D';   ten := 'M';  end;
      1000: begin  one := 'M'; five := 'm';   ten := 'n';  end;

    case digit of
      0: get_roman := '';
      1: get_roman := one;
      2: get_roman := one + one;
      3: get_roman := one + one + one;
      4: get_roman := one + five;
      5: get_roman := five;
      6: get_roman := five + one;
      7: get_roman := five + one + one;
      8: get_roman := five + one + one + one;
      9: get_roman := one + ten;

    write ('Enter year: ');
    readln (year);

    roman := '';
    mag   := 1000;
    while (mag > 0) do
      roman := roman + get_roman (year div mag, mag);
      year  := year mod mag;
      mag   := mag  div 10;

    writeln (roman);

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Oooo... if you turn in that code, it will be too complex, and your teacher will know you cheated!  Chadd, reject this answer and I will post my simplfied version, so your teacher will not suspect your using other sources!  :)
And what makes it so complex? ;-)
Become a Certified Penetration Testing Engineer

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

Oh, I don't know.  I just wanted the points.  :)  It just seems that this source code would come from someone who knew how to do simple Pascal programs, not someone who is struggling through the class, which, I assume, chadd is...  But basically, all I wanted was the points!  :)
I thought so. ;-)  I am pretty sure that this code is about the
simplest it can get, considering that the Roman numeral system
is so haphazard in the first place.  Cheers. :-)

chadd082197Author Commented:
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today

From novice to tech pro — start learning today.