Platinum Partner

Find Min/Max Of A Porabola

// Short snippet that takes 3 integers and gives you the min/max location of a parabola


public class mainClass2 {
	//Finds parabola min/max
	public static void main(String args[]){
		int a = 29;
		int b = -31;
		int c = 99;
		
		float x = findX(a,b);
		float y = findY(a,b,c,x);
		
		if (a < 0){
			System.out.println("max: x="+ x + " y=" + y);
		}
		else{
			System.out.println("min: x="+ x + " y=" + y);
		}
	}
	
	public static float findX(float a, float b){
		if (a == 0){
			return -1;
		}
		else{
			return (-b)/(2*a);
		}
	}
	public static float findY(float a, float b, float c, float x){
		return a*(x*x) + (b*x) + c;
	}
}
{{ tag }}, {{tag}},

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}
{{ parent.authors[0].realName || parent.author}}

{{ parent.authors[0].tagline || parent.tagline }}

{{ parent.views }} ViewsClicks
Tweet

{{parent.nComments}}