SHARE
TWEET
Untitled
a guest
Jan 29th, 2018
55
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
- public static String getImproper(String a) {
- if (a.indexOf("_") < 0) {
- if (a.indexOf("/") < 0) {
- return (a + "/1");
- }
- else
- return a;
- }
- else {
- String denomS = "";
- String numeratorS = "";
- String wholeNumberS = "";
- denomS = a.substring(a.indexOf("/") + 1);
- numeratorS = a.substring(a.indexOf("_") + 1, a.indexOf("/"));
- wholeNumberS = a.substring(0, a.indexOf("_"));
- int wholeNumber = Integer.parseInt(wholeNumberS);
- int denom = Integer.parseInt(denomS);
- int numerator = Integer.parseInt(numeratorS);
- String output = (((wholeNumber * denom) + numerator) + "/" + denom);
- System.out.printf("%s", output);
- return output;
- }
- }
RAW Paste Data

