Guest User

Untitled

a guest
May 17th, 2012
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.55 KB | None | 0 0
  1. public class Parabola {
  2.     //Finds parabola min/max
  3.     public static void main(String args[]){
  4.         int a = 29;
  5.         int b = -31;
  6.         int c = 99;
  7.        
  8.         float x = findX(a,b);
  9.         float y = findY(a,b,c,x);
  10.        
  11.         if (a < 0){
  12.             System.out.println("max: x="+ x + " y=" + y);
  13.         }
  14.         else{
  15.             System.out.println("min: x="+ x + " y=" + y);
  16.         }
  17.     }
  18.    
  19.     public static float findX(float a, float b){
  20.         if (a == 0){
  21.             return -1;
  22.         }
  23.         else{
  24.             return (-b)/(2*a);
  25.         }
  26.     }
  27.     public static float findY(float a, float b, float c, float x){
  28.         return a*(x*x) + (b*x) + c;
  29.     }
  30. }
Advertisement
Add Comment
Please, Sign In to add comment