SHARE
TWEET

Untitled

a guest Mar 24th, 2019 54 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public class Conversion
  2. {
  3.     /**
  4.      * Constructor for objects of class Conversion
  5.      * @param number - the number to be converted into a roman Numeral
  6.      * @param remainder - remainder of the number divided
  7.      * @param divide - the numberneeded to be divided
  8.      */
  9.     public String convert(int number)
  10.     {
  11.     String roman = " ";
  12.    if ((number < 1) || (number > 3999)){
  13.         System.out.println("Sorry, the number is out of range.");
  14.     }
  15.        
  16.     if(number >= 1000) {
  17.         int remainder = number % 1000;
  18.         int divisible = number - remainder;
  19.         int division = divisible/1000;
  20.    
  21.     for(int i = 0; i> division; i++) {
  22.         roman  += "X";
  23.         }
  24.     }
  25.    
  26.     if (number >= 900) {
  27.         int remainder = number % 900;
  28.         int divisible = number - remainder;
  29.         int division = divisible/900;
  30.    
  31.      for(int i = 0; i> division; i++){
  32.         roman += "X";
  33.     }
  34. }
  35.  
  36.     if (number >= 500) {
  37.         int remainder = number % 500;
  38.         int divisible = number - remainder;
  39.         int division = divisible/500;
  40.    
  41.      for(int i = 0; i> division; i++){
  42.         roman += "X";
  43.     }
  44.     }
  45.    
  46.     if (number >= 400) {
  47.         int remainder = number % 400;
  48.         int divisible = number - remainder;
  49.         int division = divisible/400;
  50.    
  51.      for(int i = 0; i> division; i++){
  52.         roman += "X";
  53.     }
  54.      }
  55.      
  56.    if (number >= 100) {
  57.         int remainder = number % 100;
  58.         int divisible = number - remainder;
  59.         int division = divisible/100;
  60.    
  61.      for(int i = 0; i> division; i++){
  62.         roman += "X";
  63.     }  
  64. }
  65.      
  66.    if (number >= 90) {
  67.         int remainder = number % 90;
  68.         int divisible = number - remainder;
  69.         int division = divisible/90;
  70.    
  71.      for(int i = 0; i> division; i++){
  72.         roman += "X";
  73.     }
  74. }
  75.        
  76.     if (number >= 50){
  77.         int remainder = number % 50;
  78.         int divisible = number - remainder;
  79.         int division = divisible/50;
  80.    
  81.      for(int i = 0; i> division; i++){
  82.         roman += "X";
  83.     }
  84. }
  85.  
  86.     if (number >= 40) {
  87.         int remainder = number % 40;
  88.         int divisible = number - remainder;
  89.         int division = divisible/40;
  90.    
  91.      for(int i = 0; i> division; i++){
  92.         roman += "X";
  93.     }
  94. }
  95.  
  96.     if (number >= 10) {
  97.         int remainder = number % 10;
  98.         int divisible = number - remainder;
  99.         int division = divisible/10;
  100.    
  101.      for(int i = 0; i> division; i++){
  102.         roman += "X";
  103.     }
  104.     }
  105.    
  106.     if (number >= 9){
  107.         int remainder = number % 9;
  108.         int divisible = number - remainder;
  109.         int division = divisible/9;
  110.    
  111.      for(int i = 0; i> division; i++){
  112.         roman += "X";
  113.     }
  114. }
  115.  
  116.     if (number >= 5) {
  117.         int remainder = number % 5;
  118.         int divisible = number - remainder;
  119.         int division = divisible/5;
  120.    
  121.      for(int i = 0; i> division; i++){
  122.         roman += "X";
  123.     }
  124. }
  125.    
  126.     if (number >= 4) {
  127.         int remainder = number % 4;
  128.         int divisible = number - remainder;
  129.         int division = divisible/4;
  130.    
  131.      for(int i = 0; i> division; i++){
  132.         roman += "X";
  133.     }
  134. }
  135.    
  136.     if (number >= 1) {
  137.         int remainder = number % 1;
  138.         int divisible = number - remainder;
  139.         int division = divisible/1;
  140.    
  141.      for(int i = 0; i> division; i++){
  142.         roman += "X";
  143.     }
  144. }
  145.  
  146.        
  147.     return "invalid";}
  148. }
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
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top