Skip to content

Instantly share code, notes, and snippets.

@averj
averj / round.php
Created May 18, 2014 03:25
round.php
<?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;
@averj
averj / Converter.java
Last active January 22, 2024 00:47
Roman Numeral Converter
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