So I just finished up a way to solve Standard Form Quadratic Equations, Now I want to code a way to automatically Convert a given Standard Form equation to Vertex Form, or Vertex to Standard. Is it possible due to the fact that you have to get a perfect square binomial? Could you just use the Square Root of h in y = a(x-h)^2+k?
I've searched google and elsewhere with no luck finding code for a converter. So I came here for a start.
package com.github.geodox.quadraticconverter;
import java.util.Scanner;
public class QuadraticConverter
{
public static void main(String[] args)
{
Scanner s = new Scanner(System.in);
String newEquation = null;
System.out.println("Standard to Vertex? Type stv");
System.out.println("Vertex to Standard? Type vts");
String option = s.nextLine();
//Standard to Vertex
if(option == "stv")
{
double a, b, c;
//Take Inputs
System.out.println("Equation: y = ax^2 + bx + c");
System.out.println("Input a: ");
a = s.nextDouble();
System.out.println("Input b: ");
b = s.nextDouble();
System.out.println("Input c: ");
c = s.nextDouble();
System.out.println("Standard Form: y = " + a + "x^2 + " + b + "x + " + c);
//Convert Equation
//Print Resulting Equation
System.out.println("Vertex Form: " + newEquation);
}
//Vertex to Standard
else if(option == "vts")
{
double x, h;
//Take Inputs
System.out.println("Equation: y = a(x-h)^2 + k");
System.out.println("Input x: ");
x = s.nextDouble();
System.out.println("Input k: ");
h = s.nextDouble();
System.out.println("Vertex Form: y = a(" + x + " - " + h + ") + k");
//Convert Equation
//Print Resulting Equation
System.out.println("Standard Form: " + newEquation);
}
//Invalid Response
else
System.out.println("Invalid Response");
s.close();
}
}
Here is what I've done so far.
I can't find what is done in each step of conversion. That should at least get me started.