public class Base{ //This class converts decimal numbers to any base from 2 - 10
private
private
private
private
private
private
int _base;
int _num;
boolean _pError1; //Parameter error variable
boolean _pError2;
boolean bError;
boolean nError;
}
for(int i = 0; i < output.length(); i++){ //Gets rid of all the excess zer
os in front of the converted number
if(output.charAt(i) == '0')
flag++;
else
break;
}
if(flag == output.length()) //If all the digits of the converted number ar
e zero,
//then this sets the String to "0"
output = "0";
else
output = output.substring(flag, output.length()); //If not all digits
are zero, then this shortens the output
if(oError == true) //Error is thrown if the converted number exceeds the 1
6-bit limit
output = "\nError: Overflow";
if(_pError1 == true && _pError2 == true) //Error is thrown if no parameter
s were assigned to convert() or to
//the object when it was instanti
ated
output = "\nError: No Parameters Given";
}
if(bError == true) //Error is thrown if the base is invalid
output = "\nError: Invalid Base";
if(nError == true) //Error is thrown if the number is invalid
output += "\nError: Invalid Number";
return output; //Returns the converted number and/or any errors
}
}