#include <stdio.h>
#include <math.h>

int a,b,c;
float retval;
char currentval[1];
float solutions[2];

int prompt(currentval) {
	printf("Please Input the value of %s:\n",currentval);
	scanf("%f",&retval);
	return retval;
}

int quadrat() {
	if(((b^2) - (4*a*c)) >= 0) {            
		solutions[1] = (-b + (sqrt(pow(b,2)-(4*a*c))))/(2*a);
                solutions[2] = (-b - (sqrt(pow(b,2)-(4*a*c))))/(2*a);
		printf("Solution 1 = %f:\n",solutions[1]);
	        printf("Solution 2 = %f:\n",solutions[2]);

		if(solutions[1] == floor(solutions[1]) && solutions[2] == floor(solutions[2])) {
			printf("\n Though you probably already knew this, these are easily factored\n");
			printf("Factors of the polynomial: \n(x");
			if(solutions[1] > 0) {
				printf("+%f)",solutions[1]);
			} 
			else {
				printf("%f)",solutions[1]);
			}
			printf("And (x");
			if(solutions[2] > 0) {
				printf("+%f)",solutions[2]);
			} 
			else {
				printf("%f)",solutions[2]);
			}			
		}

	}
	else {
		printf("\nSorry, no real solutions.  We aren't skilled enough to provide a complex answer\n");
	}
}

int main() {
	puts("------------------------------------------------------------------------------------------");
	puts("Welcome to the Quadratic Calculator!");
	a = prompt("a");
	b = prompt("b");
	c = prompt("c");
	if(a == 0) {
	printf("\nWhat are you trying to pull? This is not a quadratic polynomial!!!\n Let's try and see if you can't come up with a better value for the leading coefficient.\n");	
	main();
	}
	else {
	quadrat();		
	}
        puts("\n------------------------------------------------------------------------------------------");
}