This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
function round($num) { | |
$conversions = array( // Add whatever conversion is needed | |
(float)1000000 => 'billion', | |
1000000 => 'million', | |
1000 => 'thousand' | |
); | |
foreach($conversions as $key => $val) { | |
if(($num / $key) >= 1) { | |
return round($num / $key, 1) . ' ' . $val; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package me.javersano.cs; | |
public class Converter { | |
public final int[] NUMBER_VALUES = { 1000, 900, 500, 400, 100, 90, 50, 40, 10, 9, 5, 4, 1 }; // array containing all of the values | |
public final String[] NUMBER_LETTERS = { "M", "CM", "D", "CD", "C", "XC", "L", "XL", "X", "IX", "V", "IV", "I" }; // array containing all of the numerals | |
/** | |
* Method used to convert a string to a integer | |
* @param roman roman numeral to be converted |