CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Intermediate:
program to convert english numeral to roman numeral

 



jkjha
Novice

Jan 23, 2012, 10:46 PM

Post #1 of 12 (1878 views)
program to convert english numeral to roman numeral Can't Post

Write a program that will accept a number as input and then will translate it into Roman numerals. Remember that:

1 = I
5 = V
10 = X
50 = L
100 = C
500 = D
1000 = M


hostage
Novice

Jan 24, 2012, 12:24 AM

Post #2 of 12 (1876 views)
Re: [jkjha] program to convert english numeral to roman numeral [In reply to] Can't Post

easy!


rovf
Veteran

Jan 24, 2012, 12:56 AM

Post #3 of 12 (1875 views)
Re: [jkjha] program to convert english numeral to roman numeral [In reply to] Can't Post


Quote
Write a program ...


????

What for should I write such a program?


jkjha
Novice

Jan 24, 2012, 1:05 AM

Post #4 of 12 (1874 views)
Re: [rovf] program to convert english numeral to roman numeral [In reply to] Can't Post

Ofcourse in perl...vice-versa is easy but this one seems tough


jkjha
Novice

Jan 24, 2012, 1:06 AM

Post #5 of 12 (1873 views)
Re: [hostage] program to convert english numeral to roman numeral [In reply to] Can't Post

If u know then post it..>I m unable to code and even not found in internet


hostage
Novice

Jan 24, 2012, 1:20 AM

Post #6 of 12 (1865 views)
Re: [jkjha] program to convert english numeral to roman numeral [In reply to] Can't Post

at least edit you're post and write an example of input & output maybe it'll be more clear.


saurabhsharma
Novice

Jan 24, 2012, 1:30 AM

Post #7 of 12 (1863 views)
Re: [jkjha] program to convert english numeral to roman numeral [In reply to] Can't Post

Please don't post your homework/class assignments here.

If you really want some help try it out yourself, if you get stuck somewhere we would be more than happy to help.

but don't expect any one to write whole code ("program" in your case) for you.

Anyway you first find the total number of digits passed and then process accordingly lets say if the digit passed is 549, count the digits here its 3 so now you process the first digit(u can use switch case) and get the corresponding value. Likewise do it for all the digits and calculate the roman form.


rovf
Veteran

Jan 24, 2012, 1:31 AM

Post #8 of 12 (1863 views)
Re: [jkjha] program to convert english numeral to roman numeral [In reply to] Can't Post

Jkjha,

maybe you misunderstood the purpose of this forum: This is to help people who are starting with Perl. This means, if you have concrete questions about how a certain Perl construct works, or don't see why your program does not work, you find help here. This means that we need to see at least some code, to be able to discuss it.

I thought your intention is to learn Perl, but it seems that you are not a programmer yourself, but looking for someone to implement your program. This is perfectly fine (actually, I earn my living by doing contract programming), but a forum for offering programming jobs would be more appropriate for this kind of posting.

Hope that helps.


rovf
Veteran

Jan 24, 2012, 1:33 AM

Post #9 of 12 (1862 views)
Re: [jkjha] program to convert english numeral to roman numeral [In reply to] Can't Post


Quote
Ofcourse in perl


I did not ask in what language we should write the program, but to what purpose we should write that program? Is this kind of a programming quiz???


jkjha
Novice

Jan 24, 2012, 2:08 AM

Post #10 of 12 (1858 views)
Re: [hostage] program to convert english numeral to roman numeral [In reply to] Can't Post


In Reply To
at least edit you're post and write an example of input & output maybe it'll be more clear.


Input- 15
output- XV

Input-44
output-XLIV


BillKSmith
Veteran

Jan 24, 2012, 6:31 AM

Post #11 of 12 (1844 views)
Re: [jkjha] program to convert english numeral to roman numeral [In reply to] Can't Post

Hint: Roman numerals are a base-10 system, the same as decimal. Therefore, for any number, every symbol (digit) in the decimal number has a corresponding symbol in the Roman numeral. The Roman symbol consists of zero to four characters.

Hint: It is easier to determine the decimal place value of each digit if you process the decimal number backwards.
Good Luck,
Bill


rovf
Veteran

Jan 24, 2012, 8:17 AM

Post #12 of 12 (1840 views)
Re: [jkjha] program to convert english numeral to roman numeral [In reply to] Can't Post

One more hint, in addition to Bill's:

Don't think about your decimal input as "numbers". Think of it as strings - you don't need arithmetic here.

Have a look at the substr function, which you can use to easily extract the rightmost digit. For example, subst(345,-1) yields 5.

 
 


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives