public class Roots {
static void main (String[] args) {
//Generally, I find it better to declare your variables and types before using them
double a, b, c; // (a,b,c are inputs in the quatratic eqation)
double yards; //amount of yards
double total; //total for the entire cost
double equation; //to set equation in normal form
//distance from roots (should always be positive.
double distance;
//first (adding) and second (subtracting) root of the equation
int r1, r2;
double disciminant; //
a = Integer.parseInt(args[0]); //assign the first runtime input to a
b = Integer.parseInt(args[1]); //assign the second runtime input to b
c = Integer.parseInt(args[2]); //assign the third runtime input to c
return a,b,c;
//discriminant assumes that the user inputs three values. this creates real, non imaginary solutions
discriminant = ( Math.pow(b, 2) - (4 * a * c) )
equation = (a*(Math.pow(x,2)) - (b*x) + c ); //create the quadriatic equation of form ax^2+ bx + C = 0
r1 = (-b + discriminant); //calculate the first root for the first root solution for the quadriatic
r2 = (-b - discriminant); //calculate the second root
//calculate the distance between the roots which should *always* be positive
distance = Math.abs(r1-r2);
yards = Double.parseDouble(args[3]); // fourth runtime variable is the price for the fence in dollars/yard
total = (distance * yards); //calculate the total for the fence
return system.out.println( "your total is" + total + "for the fence");
}
}