Monday, November 25, 2019

Decimal To Roman Numeral Converter in JavaScript

I wrote this program to ask the user to give a year and then the program will convert the given decimal number into roman numeral equivalent using JavaScript.

I am currently accepting programming work, IT projects, school and application development, programming projects, thesis and capstone projects, IT consulting work, computer tutorials, and web development work kindly contact me in the following email address for further details.  If you want to advertise on my website kindly contact me also in my email address also. Thank you.

My email address is the following jakerpomperada@gmail.com, jakerpomperada@aol.com, and jakerpomperada@yahoo.com.

My mobile number here in the Philippines is 09173084360.

My telephone number at home here in Bacolod City, Negros Occidental Philippines is  +63 (034) 4335675.

Here in Bacolod City, Negros Occidental I also accepting computer repair, networking and Arduino Project development at a very affordable price.

My Facebook address is https://www.facebook.com/profile.php?...

My personal website is http://www.jakerpomperada.com

My programming website is http://www.jakerpomperada.blogspot.com

I am also a book author you can purchase my books on computer programming and information technology in the following links below.



Thank you very much for your help and support.




Sample Program Output


Program Listing

index.htm

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<html>
<head>
<title>Decimal To Roman Numeral Converter in Javascript</title>
</head>
<script>

function integer_to_roman(num) {
if (typeof num !== 'number') 
return false; 

var digits = String(+num).split(""),
key = ["","C","CC","CCC","CD","D","DC","DCC","DCCC","CM",
"","X","XX","XXX","XL","L","LX","LXX","LXXX","XC",
"","I","II","III","IV","V","VI","VII","VIII","IX"],
roman_num = "",
i = 3;
while (i--)
roman_num = (key[+digits.pop() + (i * 10)] || "") + roman_num;
return Array(+digits.join("") + 1).join("M") + roman_num;
}

function processFormData() 
{

  var inputs = parseInt(document.getElementById('txt_name').value);

    alert("The equivalent in roman numeral is " + integer_to_roman(inputs));
  
}
</script>
<body>
<br>
<h3> Decimal To Roman Numeral in JavaScript </h3>
<div>
<p><label for="name">Give Decimal Number: </label><input type="text" name="name" id="txt_name"></p>
<p><input type="button" name="submit" value="submit" onclick="processFormData();" ></p>
</div> 
</body>
</html>

No comments:

Post a Comment