daily pastebin goal
41%
SHARE
TWEET

Untitled

a guest Jan 29th, 2018 55 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. public static String getImproper(String a) {
  2.         if (a.indexOf("_") < 0) {
  3.             if (a.indexOf("/") < 0) {
  4.                 return (a + "/1");
  5.             }
  6.             else
  7.                 return a;
  8.         }
  9.         else {
  10.             String denomS = "";
  11.             String numeratorS = "";
  12.             String wholeNumberS = "";
  13.             denomS = a.substring(a.indexOf("/") + 1);
  14.             numeratorS = a.substring(a.indexOf("_") + 1, a.indexOf("/"));
  15.             wholeNumberS = a.substring(0, a.indexOf("_"));
  16.            
  17.             int wholeNumber = Integer.parseInt(wholeNumberS);
  18.             int denom = Integer.parseInt(denomS);
  19.             int numerator = Integer.parseInt(numeratorS);
  20.            
  21.             String output = (((wholeNumber * denom) + numerator) + "/" + denom);
  22.             System.out.printf("%s", output);
  23.            
  24.             return output;
  25.            
  26.         }
  27.            
  28.     }
RAW Paste Data
Pastebin PRO WINTER Special!
Get 40% OFF Pastebin PRO accounts!
Top