Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Parabola {
- //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;
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment