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 |
DNA pairing | 1,854 Kb |
Culinary Arts Institute at MCCC | 6,079 Kb |
Random Quote Machine Complete | 4,076 Kb |
WhatIsInAName | 2,583 Kb |
Black Leopard | 2,001 Kb |
Tribute Page | 3,131 Kb |
Wikipedia Viewer | 2,665 Kb |
AngularJS | 2,021 Kb |
Smallest Common Multiple | 2,702 Kb |
Culinary Arts Institute | 6,040 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 |
Google Fonts Sass Mixin | HugoGiraudel | 4,237 Kb |
Underlined form fields | Mitchdot | 2,323 Kb |
CSS Bot Confusion | Jpod | 3,456 Kb |
Responsive Section hover effect to show content | Berdejitendra | 2,540 Kb |
Popup Modal | Aldlevine | 3,696 Kb |
Shape Outside - Polygon | Stacy | 3,954 Kb |
Obligatory CSS3 UI Nav | Romandiaz | 9,017 Kb |
Sticky footer testing | 75th | 1,649 Kb |
CSS3 iPad | Vikvarg | 1,766 Kb |
A Pen by Gregory Potdevin | GregoryPotdevin | 1,713 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!