Roman numeral program 
Author Message
 Roman numeral program

I need to write a prgram that reads in roman numerals and outputs the
regular number.I also need to check if the roman numeral is valid within
the prgram.If anyone can help please emial me ASAP.
Thanks




Wed, 18 Jun 1902 08:00:00 GMT  
 Roman numeral program

interesting idea...
what about assigning the number value of the letter to the letter
like:
I = 1
V = 5
X = 10
etc...
then adding them together from the user input.

--


: I need to write a prgram that reads in roman numerals and outputs
the
: regular number.I also need to check if the roman numeral is valid
within
: the prgram.If anyone can help please emial me ASAP.
: Thanks
:

:



Wed, 18 Jun 1902 08:00:00 GMT  
 Roman numeral program

Quote:
> I need to write a prgram that reads in roman numerals and outputs the
> regular number.I also need to check if the roman numeral is valid within
> the prgram.If anyone can help please emial me ASAP.

   Here's some help:
  1. Stay awake in class.
  2. Read your study material.
  3. Ask your teacher for help.
  4. Study the _data_ involved in the problem and consider how _you_
would do it if you didn't have to program it.
  5. Write down all the things _you_ would do to accomplish the task (if
you didn't have to program it).
  6. Translate what you wrote down into the target language you're
required to use (Pascal, presumably).
  7. Test your program with various values which you know produced
certain expected results.
  8. Test your program with invalid and boundary values, to assure your
program handles all data possibilities.
  9. Turn in your completed program.
   FYI, the above directions apply to all the programs and tasks you'll
have...


Wed, 18 Jun 1902 08:00:00 GMT  
 Roman numeral program

On 9 Oct 1997 18:27:34 GMT, Ihsan G. Beezer sez::

Quote:
>I need to write a prgram that reads in roman numerals and outputs the
>regular number.I also need to check if the roman numeral is valid within
>the prgram.If anyone can help please emial me ASAP.

Man, I don't know how I ever got my homework done before there was an
internet... :-{)

--------------------

all adverti{*filter*}ts will be returned to your postmaster



Wed, 18 Jun 1902 08:00:00 GMT  
 Roman numeral program

Quote:

>interesting idea...
>what about assigning the number value of the letter to the letter
>like:
>I = 1
>V = 5
>X = 10
>etc...
>then adding them together from the user input.

Depending on the form used you may have to consider the adjacent
characters to know whether to add as in VII, LX, etc, or
subtract as in IV, IX, XLIX, etc.

    ...red

--
Support the anti-Spam amendment
  Join at http://www.cauce.org/



Wed, 18 Jun 1902 08:00:00 GMT  
 Roman numeral program



Quote:
>I need to write a prgram that reads in roman numerals and outputs the
>regular number.I also need to check if the roman numeral is valid within
>the prgram.If anyone can help please emial me ASAP.

Manners : QHAH.  Please also learn about proper cross-posting.

http://www.merlyn.demon.co.uk/programs/wr-roman.pas  may help you with
your testing.

--

  Web URL: http://www.merlyn.demon.co.uk/ - FAQqish topics, acronyms and links.
  Correct 4-line sig separator is as above, a line comprising "-- " (SoRFC1036)
  Before a reply, quote with ">" / "> ", known to good news readers (SoRFC1036)



Wed, 18 Jun 1902 08:00:00 GMT  
 Roman numeral program

Hmmm...I tried a program like that a few years ago.
Yuch.
I used an enumerated type

type
   roman = (I,V,X,L,C,D,M);

but don't forget--there be some mighty funny rules...
like an I before a V,X,L,C,D or M means subtraction, and whatnot.

Using an enumerated type requires that you convert and do the
math in your conversion functions.
However, this WILL make the program a whole lot easier.

Hope it helps...

--
***************************************
!  You've been mailed by the Mad Cow.
http://members.tripod.com/~VacaLoca
My ICQ UIN is 1800067...try it!
http://www.mirabilis.com
***************************************



Wed, 18 Jun 1902 08:00:00 GMT  
 Roman numeral program

Quote:



> : On 9 Oct 1997 18:27:34 GMT, Ihsan G. Beezer sez::
> : >I need to write a prgram that reads in roman numerals and outputs
> the
> : >regular number.I also need to check if the roman numeral is valid
> within
> : >the prgram.If anyone can help please emial me ASAP.
> :
> : Man, I don't know how I ever got my homework done before there was
> an
> : internet... :-{)
> what is the point of taking a class to learn a language if you are
> not even going to do the work yourself?

Sometimes it is important to read (see)  programs before you write
them for yourself, just like reading came before writing.  In order
to write well it is important to read "good" programs.  Another approach
some teachers / professors are using is to put less emphasis on assignments
(because of group assistance) and more emphasis on tests or exams later.

It is difficult for teachers or professors to realize how difficult
language syntax is especially in C (even though students know Basic or
Pascal).

The program code is only  half the marks. The rest is based on style,
documentation and extensive testing.

My 2 cents
--

              fax number     1-613-224-0805
-----------------------------------------------------------------



Wed, 18 Jun 1902 08:00:00 GMT  
 Roman numeral program



:


: > : On 9 Oct 1997 18:27:34 GMT, Ihsan G. Beezer sez::
: > : >I need to write a prgram that reads in roman numerals and
outputs
: > the
: > : >regular number.I also need to check if the roman numeral is
valid
: > within
: > : >the prgram.If anyone can help please emial me ASAP.
: > :
: > : Man, I don't know how I ever got my homework done before there
was
: > an
: > : internet... :-{)
:
: > what is the point of taking a class to learn a language if you
are
: > not even going to do the work yourself?
:
: Sometimes it is important to read (see)  programs before you write
: them for yourself, just like reading came before writing.  In order
: to write well it is important to read "good" programs.  Another
approach
: some teachers / professors are using is to put less emphasis on
assignments
: (because of group assistance) and more emphasis on tests or exams
later.
:
: It is difficult for teachers or professors to realize how difficult
: language syntax is especially in C (even though students know Basic
or
: Pascal).
:
: The program code is only  half the marks. The rest is based on
style,
: documentation and extensive testing.
:
: My 2 cents
: --

:               fax number     1-613-224-0805
: -----------------------------------------------------------------
:
you said reading came before writing... not true... reading came with
writing as you cant read with out having wrote



Wed, 18 Jun 1902 08:00:00 GMT  
 Roman numeral program

Hello,
Anyone tried this kind of approach (recursive) before?  This works
with illegal roman numerals as well (e.g. iiiii returns 5...).

Check it out:

const
   rval  :  array['A'..'Z'] of word = (0, 0, 100, 0, 0, 0, 0, 0, 1, 0,

                          0, 50, 1000, 0, 0, 0, 0, 0, 0, 0,
                          0, 5, 0, 10, 0, 0);

function mid(s : string; start, stop : byte) : string;
   var
      i  :  integer;
      s2 :  string;
   begin
      s2 := '';
      if start<=stop then
         for i := start to stop do
            s2 := s2+s[i];
      mid := s2;
   end;  {mid}

function roman(s : string) : word;
   var
      i, h  :  integer;
   begin
      if length(s)=0 then
         roman := 0
      else if length(s)=1 then
         roman := rval[upcase(s[1])]
      else begin
         h := 1;
         for i := 2 to length(s) do
            if rval[upcase(s[i])]>rval[upcase(s[h])] then
               h := i;
         roman := rval[upcase(s[h])]-roman(mid(s, 1,
h-1))+roman(mid(s, h+1, length(s)));
      end;  {else}
   end;  {roman}
--

{*filter*}ism Catalyst:





Wed, 18 Jun 1902 08:00:00 GMT  
 
 [ 10 post ] 

 Relevant Pages 

1. Roman Numerals Program

2. roman numeral program

3. Big Randoms (was:roman numeral program)

4. Roman numeral program

5. ROMAN NUMERAL CONVERSIONS???

6. Roman numerals (answers)

7. ROMAN NUMERAL CONVERSION???

8. HELP!: Roman Numerals! :TPW

9. ANYONE GOT ALIGORITHM TO CONVERT DECIMAL INTO ROMAN NUMERALS

10. ANYONE GOT CODE TO CONVERT DECIMAL TO ROMAN NUMERALS?

11. Cantor's numeral code

12. Stopping numeral/letter error

 

 
Powered by phpBB® Forum Software