- Google+ Tools
-
Make Google+ profile picture
Make Google plus banners for profile
Create and share your Google Plus profile banners.
- It does exactly what the title says it does. The user must put in an equation like 5x-5y=10 and x and y must be in that order.
Converting Standard Form Equations To Slope Intercept Form
public static String StandardToSlope(String Function) {
//lets loop until we find our x value
char[] Characters = Function.toLowerCase().replace(" ", "").toCharArray();
int xIndex = 0;
for (int i = 0; i < Characters.length; i++) {
if (Characters[i] == 'x') {
xIndex = i;
break;
}
}
String xValue = "";
if (Characters[0] == '-') {
xValue += "";
}
else {
xValue += "-";
}
Vector<String> xValues = new Vector<String>();
try {
for (int i = xIndex-1; i >= 0; i--) {
if (IsNumeric(String.valueOf(Characters[i]))) {
xValues.add(String.valueOf(Characters[i]));
}
}
}
catch (Exception ex) {
//do nothing
}
for (int i = xValues.size()-1; i >= 0; i--) {
xValue+=xValues.get(i);
}
//now we do the same as above except to get the y
int yIndex = 0;
for (int i = 0; i < Characters.length; i++) {
if (Characters[i] == 'y') {
yIndex = i;
break;
}
}
String yValue = "";
Vector<String> yValues = new Vector<String>();
try {
for (int i = yIndex-1; i >= 0; i--) {
if (IsNumeric(String.valueOf(Characters[i]))) {
yValues.add(String.valueOf(Characters[i]));
}
if (Characters[i] == '-' || Characters[i] == '+') {
if (Characters[i] == '-') {
yValue="-";
}
break;//reached end of y
}
}
}
catch (Exception ex) {
//do nothing
}
for (int i = yValues.size()-1; i >= 0; i--) {
yValue+=yValues.get(i);
}
//lets get the final number
int equalsIndex = Function.replace(" ", "").indexOf("=");
String FinalNumber = "";
for (int i=equalsIndex+1; i < Characters.length; i++) {
FinalNumber += String.valueOf(Characters[i]);
}
if (IsNumeric(String.valueOf(FinalNumber.charAt(0)))) {
FinalNumber = "+" + FinalNumber;
}
//finish it up then return
double finalXValue = Double.parseDouble(xValue)/Double.parseDouble(yValue);
double finalFinalNumber = Double.parseDouble(FinalNumber)/Double.parseDouble(yValue);
String Oper = (IsNegative(finalFinalNumber)) ? "" : "+";
//String finalFinalFinalNumber =
return "y="+finalXValue+"x"+Oper+finalFinalNumber;
}
//checks if a string is a single numerical character
//i know it is not the best for normal use
//but good for this function
public static Boolean IsNumeric(String Value) {
Boolean returns = false;
if (Value.contains("0") || Value.contains("1") || Value.contains("2") || Value.contains("3") || Value.contains("4") || Value.contains("5") || Value.contains("6") || Value.contains("7") || Value.contains("8") || Value.contains("9")) {
returns = true;
}
return returns;
}
//checks if a double is negative
public static Boolean IsNegative(double value) {
if (value < 0) {
return true;
}
else {
return false;
}
}
Comments
blog comments powered by Disqus