Roman Numerical Converter
How do I make an roman numerical converter?
What is a roman numerical converter? How do you make a roman numerical converter? This script and codes were developed by Victor Hall on 23 September 2022, Friday.
Roman Numerical Converter - Script Codes HTML Codes
<!DOCTYPE html>
<html >
<head> <meta charset="UTF-8"> <title>Roman Numerical Converter</title>
</head>
<body> <!--<div id="test"></div>--> <script src="js/index.js"></script>
</body>
</html>
Roman Numerical Converter - Script Codes JS Codes
function convertToRoman(num) { var result = num; var answer = []; var temp = 0; //test if number is greater than or equal to 1000 if((result / 1000) >= 1){ temp = result; //Returns how many times the number goes into 1000 temp = temp / 1000; //rounds down to get a whole number temp = Math.floor(temp); //Adds that appropriate n quantities to the array for(var i = 0; i < temp; i++){ answer.push("M"); } //converts number in terms of 100 since there are not more // 1000s left in it result = result % 1000; } //This takes care of the special case //Since you cannot have 4 C's, this handles all //numbers between 900 to 10000 if((result < 1000) && (result >=900)){ answer.push("CM"); result = result - 900; } //test if number is greater than or equal to 500 if((result / 500) >= 1){ temp = 0; temp = result; //Returns how many times the number goes into 500 temp = temp / 500; //Rounds down temp = Math.floor(temp); for(var o = 0; o < temp; o++){ answer.push("D"); } //converts number in terms of 100 since there are not more // 500s left in it result = result % 500; }
if((result / 100) >= 1){ temp = 0; temp = result; temp = temp / 100; temp = Math.floor(temp); for(var p = 0; p < temp; p++){ answer.push("C"); } result = result % 100; } if((result < 100) && (result >= 90)){ answer.push("XC"); result = result - 90; }
if((result / 50) >= 1){ temp = 0; temp = result; temp = temp / 50; temp = Math.floor(temp); for(var a = 0; a < temp; a++){ answer.push("L"); } result = result % 50; } if((result / 10) >= 1){ temp = 0; temp = result; temp = temp / 10; temp = Math.floor(temp); if(temp > 3){ answer.push("XL") } if(temp <= 3){ for(var s = 0; s < temp; s++){ answer.push("X"); } } result = result % 10; } if(result == 9 ){ temp = 0; answer.push("IX"); result = result % 9; } if((result / 5) >= 1){ temp = 0; temp = result; temp = temp / 5; temp = Math.floor(temp); for(var f = 0; f < temp; f++){ answer.push("V"); } result = result % 5; } if((result / 1) >= 1){ temp = 0; temp = result; temp = temp / 1; temp = Math.floor(temp); if(temp > 3){ answer.push("IV") } if(temp <= 3){ for(var g = 0; g < temp; g++){ answer.push("I"); } } result = result % 1; } var list = answer.join(''); alert(list) //document.getElementById('').innerHTML = answer;
}
convertToRoman(3999);
Developer | Victor Hall |
Username | vhall_io |
Uploaded | September 23, 2022 |
Rating | 3 |
Size | 2,102 Kb |
Views | 22,264 |
Find the perfect freelance services for your business! Fiverr's mission is to change how the world works together. Fiverr connects businesses with freelancers offering digital services in 500+ categories. Find Developer!
Name | Size |
Steamroller | 1,888 Kb |
Culinary Arts Institute | 6,040 Kb |
Drop it | 1,699 Kb |
Culinary Arts Institute at MCCC | 6,079 Kb |
FCC Test | 1,652 Kb |
AngularJS | 2,021 Kb |
Wikipedia Viewer | 2,665 Kb |
DNA pairing | 1,854 Kb |
Everything be true | 1,626 Kb |
Pig Latin | 1,837 Kb |
Jasper is the AI Content Generator that helps you and your team break through creative blocks to create amazing, original content 10X faster. Discover all the ways the Jasper AI Content Platform can help streamline your creative workflows. Start For Free!
Name | Username | Size |
CSS3 Animated buttons | Cguillou | 3,737 Kb |
Codero Sitemap | S1m0ne | 28,169 Kb |
Large canvas mousemove experiment | Jibbon | 2,885 Kb |
Wrap_Test | Mscfourn | 7,503 Kb |
Loader | MikitaLisavets | 3,321 Kb |
Scroll Arrow | Robooneus | 4,437 Kb |
CSS Letter animations | Sladix | 2,116 Kb |
Mondrian | Chrisarmstrong | 2,787 Kb |
Layout 11 | Altynai | 1,690 Kb |
Z-index demo | Kblh | 1,534 Kb |
Surf anonymously, prevent hackers from acquiring your IP address, send anonymous email, and encrypt your Internet connection. High speed, ultra secure, and easy to use. Instant setup. Hide Your IP Now!