Big assignment problem that you're all going to do for me! 
Author Message
 Big assignment problem that you're all going to do for me!

Well, probably not, but still...

Hello everybody!
                Well, the subject says it all.  I was given an assignment
last week that, at present, is finished up to the last little procedure
and it is absolutely killing me.  Of course, I'm not going to ask anybody
to code it for me as I'm quite capable of doing it myself; but the
algorithm is causing some problems.  You see, the thing is that I am to
write a roman calculator thingie and the answer is to be output in roman
numerals.  The thing I am having problems with is taking the output and
finding out how many thousands, hundreds, tens and ones are in the answer.
I have done the same type of problem previously (Finding how many
Dollars, quarters, nickels and dimes make a given argument), only a few
months ago actually, and this is the reason why I'm so utterly pissed off
as I can't remember how to do it!  I vaguely remember using the MOD
operator, but I tinkered for a long while and couldn't get a satisfactory
result.  The procedure works alright as is (A *crapload* of
IF...THEN...ELSE's) but I am absolutely positive the solution can be found
in a more sophisticated manner.  Ack!  I'm a desperate man here, I'll do
anything for the answer. Anything!!!
Thanks to those who help me... &8)

                        .Mik.

    [ Do what thou wilt shall be the whole of the Law - A. Crowley ]
              :: Remove .spamitech from my addy to reply ::
Goth.Code 3.1 GoCS3DJ5  TSeGYrv8  P{*filter*}c  B11/21Bk!"1  cBu(Bk)-w6G  V6S

v8MS  r8I  p1ZZZZZz775Zz  D77~  h8(TFeDPPeSa)  sM5SSsNy  k6mDPTZ  N??93O
RfmS  LauQLD7
                :: Good god!!  My signature is a man! ::



Sat, 26 Feb 2000 03:00:00 GMT  
 Big assignment problem that you're all going to do for me!

In article <Pine.SOL.3.94.970909122057.14890E-


Quote:

>You see, the thing is that I am to
>write a roman calculator thingie ...

I was going to give you an answer here; but as you've posted a 46K ZIP
binary attachment to c.l.p.m, I won't.

--

  Web URL: http://www.merlyn.demon.co.uk/ -- includes FAQqish topics 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)



Sat, 26 Feb 2000 03:00:00 GMT  
 Big assignment problem that you're all going to do for me!

Re: Your following query

========
Newsgroups: comp.lang.Pascal.misc
Subject: Big assignment problem that you're all going to do for me!
From: "Mikhovitch (Caglios)"

Date: Tue, 9 Sep 1997 12:29:07 +1000

I am to write a roman calculator thingie and the answer is to be
output in
roman numerals.
===============================

If your input AND output are in Roman numeral form, as I am sure you
already know, you need procedures to convert a string (or array of
chars) of Roman numeral form to a decimal integer and vice versa.

A little history to help your thought process. Roman numbers come from
the way their "computers" worked. The Roman way of calculating was
like the Abacus, i.e. a biquinary system using fives and ones. They
originally drew lines in the dirt and used stones as markers. When
merchants moved inside, they painted lines on the table and that is
the origin for the English word, "counter" as in, "Take it to the
counter."

CONVERTING A DECIMAL INTEGER TO A ROMAN NUMERAL SYMBOL STRING

Assume you have the decimal number 4597. To find the right most Roman
numeral you perform-- 4597 mod 10 = 7. There are several ways to
convert 7 to VII. However, since 5, 50 and 500 all use a different
symbol (because there is no 0 symbol) you might consider:
            7 div 5 := 1, for one "V"
            7 mod 5 := 2. for two "I"s

To extract the "9", first do 4597 div 10 = 459 then:
                             459 mod 10 = 9

Although the ancient Romans did use IIII and VIIII to represent 4 and
9, this changed to the thought used in Abacus subtraction and addition

with a carry. Four is five take away one, represented as IV with 9 as
IX.

You have to keep up with the bookkeeping. This 9 really represents 90,
so the symbol is 100 - 10 or XC.

So far we have the last Roman symbols, "XCVII", with the 4500 still to
be converted.

A CASE statement is recommended for 1..3, 4, 5..8 and 9 in conjunction
with the place values, 1, 10, 100...etc to choose your symbols.

      CONVERTING AN INPUT ROMAN STRING TO A DECIMAL INTEGER

I would parse the string (or char array) from the right. As long as
the next symbol is equal or greater, keep adding 1, 10, 100... or 5,
50, 500... Any time the next symbol value is less than the previous
right symbol value, subtract this lower value from the total value.

Regards,



Sat, 26 Feb 2000 03:00:00 GMT  
 Big assignment problem that you're all going to do for me!

Quote:

> In article <Pine.SOL.3.94.970909122057.14890E-



> >You see, the thing is that I am to
> >write a roman calculator thingie ...

> I was going to give you an answer here; but as you've posted a 46K ZIP
> binary attachment to c.l.p.m, I won't.

But.. but... Okay, if I have offended you, then mores the likelihood i've
offended countless others with my shamless posting or a binary
attachment and they're not going to grace my actions with a flame.  I'm
sorry, it will *never* happen again.  Truly.  I'm sorry everybody, you
can smack me around a bit. I deserve it, I made a mistake etc etc...
(Sorry, a bit overboard, but I'm trying to show how sincere I am *8)
Thanks for the pointer...

                        .Mik.

    [ Do what thou wilt shall be the whole of the Law - A. Crowley ]
              :: Remove .spamitech from my addy to reply ::
Goth.Code 3.1 GoCS3DJ5  TSeGYrv8  P{*filter*}c  B11/21Bk!"1  cBu(Bk)-w6G  V6S

v8MS  r8I  p1ZZZZZz775Zz  D77~  h8(TFeDPPeSa)  sM5SSsNy  k6mDPTZ  N??93O
RfmS  LauQLD7
                :: Good god!!  My signature is a man! ::



Mon, 28 Feb 2000 03:00:00 GMT  
 Big assignment problem that you're all going to do for me!

In article <Pine.SOL.3.94.970911180535.17787B-


Quote:


>> In article <Pine.SOL.3.94.970909122057.14890E-



>> >You see, the thing is that I am to
>> >write a roman calculator thingie ...

>> I was going to give you an answer here; but as you've posted a 46K ZIP
>> binary attachment to c.l.p.m, I won't.

>But.. but... Okay, if I have offended you, then mores the likelihood i've
>offended countless others with my shamless posting or a binary
>attachment and they're not going to grace my actions with a flame.  I'm
>sorry, it will *never* happen again.  Truly.  I'm sorry everybody, you
>can smack me around a bit. I deserve it, I made a mistake etc etc...
>(Sorry, a bit overboard, but I'm trying to show how sincere I am *8)
>Thanks for the pointer...

In that case :

As has been said (nearly), the basic way is to use D := X mod 10 to find
the least digit of what's left, and X := X div 10 to find what's now
left - or suchlike.

But, in BP/TP, the idle, cheating, easy way is to do Str(X, S) to get an
array of characters for the digits.

Then, ISTM, for each digit, you look up the digit pattern in:
const DP : array ['0'..'9'] of string [4] =
  ('', 'x', 'xx', 'xxx', 'xy', 'y', 'yx', 'yxx', 'yxxx', 'xz') ;
then, in the resulting string, you replace xyz decade-dependently using:
const SD : array [0.. ] of array ['x'..'z'] of char =
  ('IVX', 'XLC', 'CDM', 'Mvx'...) ;
and concatenate.  Then put an overbar on each lower-case letter,
somehow.

This will handle ten decades (OK for unsigned long <g>), but I can't
recall how the Romans counted after 3999 ... lookup ... 899999.  

The tested program (and any updates) can be found at
        URL : http://www.merlyn.demon.co.uk/programs/wr-roman.pas

--

  Web URL: http://www.merlyn.demon.co.uk/ -- includes FAQqish topics 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)



Mon, 28 Feb 2000 03:00:00 GMT  
 
 [ 6 post ] 

 Relevant Pages 

1. QReport : BIG BIG Problem with memo-fields !!!

2. 'Lockfile grown too big' error

3. Delphi 1 Memo Assignment Problem - Help!

4. Paradox Memo Assignment Problem - Delphi 1- Syntax?

5. What are Y'all doing with Delphi ?

6. Demo of Apollo won't go away!

7. BDE doing things it shouldn't

8. TStringList - I'm doing something wrong here - HELP

9. Doing other people's homework

10. There's a discussion going on next-door about invalid page-faults and BDE32

11. Curser Gone after run 'NT

12. Help!!! Everything's Going Colourless

 

 
Powered by phpBB® Forum Software