daily pastebin goal
30%
SHARE
TWEET

Untitled

a guest Mar 24th, 2019 52 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /**
  2.  * converting integers to roman numerals.
  3.  *
  4.  * @author (Joesph Stella)
  5.  * @version (March, 23, 2019)
  6.  */
  7. public class Conversion
  8. {
  9.     /**
  10.      * Constructor for objects of class Conversion
  11.      * @param number - the number to be converted into a roman Numeral
  12.      */
  13.     public static String Convert(int number)
  14.     {
  15.         if ((number < 1) || (number > 3999)){
  16.             System.out.println("Sorry, the number is out of range.");}
  17.        
  18.         if (number >= 1000) {
  19.         return "M" + (number - 1000);}
  20.    
  21.         if (number >= 900)
  22.         return "CM" + (number - 900);
  23.    
  24.         if (number >= 500) {
  25.         return "D" + (number - 500);}
  26.    
  27.         if (number >= 400) {
  28.             return "CD" + (number - 400);}
  29.            
  30.         if (number >= 100) {
  31.             return "C" + (number - 100);}
  32.            
  33.         if (number >= 90) {
  34.             return "XC" + (number - 90);}
  35.            
  36.         if (number >= 50){
  37.             return "L" + (number - 50);}
  38.    
  39.         if (number >= 40) {
  40.                 return "XL" + (number - 40);}
  41.    
  42.         if (number >= 10) {
  43.                 return "X" + (number - 10);}
  44.                
  45.         if (number >= 9){
  46.             return "IX" + (number - 9);}
  47.    
  48.         if (number >= 5) {
  49.             return "V" + (number - 5);}
  50.    
  51.         if (number >= 4) {
  52.             return "IV" + (number - 4);}
  53.    
  54.         if (number >= 1) {
  55.             return "I" + (number - 1);}
  56.  
  57.         return "Invalid";
  58.     }
  59. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top