Graderpractice for programmers

Back to 254275 OOP Lab 5-10

Q10. Parabola

Problem

In mathematics, a parabola is a plane curve which is mirror-symmetrical and is approximately U-shaped. It fits several superficially different mathematical descriptions, which can all be proved to define exactly the same curves.
One description of a parabola involves a point (the focus) and a line (the directrix). The focus does not lie on the directrix. The parabola is the locus of points in that plane that are equidistant from both the directrix and the focus. Another description of a parabola is as a conic section, created from the intersection of a right circular conical surface and a plane parallel to another plane that is tangential to the conical surface.[a]
The line perpendicular to the directrix and passing through the focus (that is, the line that splits the parabola through the middle) is called the "axis of symmetry". The point where the parabola intersects its axis of symmetry is called the "vertex" and is the point where the parabola is most sharply curved. The distance between the vertex and the focus, measured along the axis of symmetry, is the "focal length". The "latus rectum" is the chord of the parabola that is parallel to the directrix and passes through the focus. Parabolas can open up, down, left, right, or in some other arbitrary direction. Any parabola can be repositioned and rescaled to fit exactly on any other parabola—that is, all parabolas are geometrically similar. write a method 6 method getLatusrectum , getVertexa, getVertexb , getFocusa, getFocusb, getDirectrix

public static void main(String[] args)
{
    Scanner in = new Scanner(System.in);
    double a = in.nextDouble();
    double b = in.nextDouble();
    double c = in.nextDouble();
    Parabola x = new Parabola(a,b,c);
    System.out.println("Latus Rectum = "+"+- "+String.format("%.2f",x.getLatusrectum(c)));
    System.out.println("Vertex: ("+String.format("%.2f",x.getVertexa(a,b))+","+String.format("%.2f",x.getVertexb(a,b,c))+")");
    System.out.println("Focus : ("+String.format("%.2f",x.getFocusa(a,b))+","+String.format("%.2f",x.getFocusb(a,b,c))+")");
    System.out.println("Directrix: y = "+String.format("%.2f",x.getDirectrix(a,b,c)));
}

Examples

Input

1
2
2

Output

Latus Rectum = +- 0.50
Vertex: (-1.00,1.00)
Focus : (-1.00,1.25)
Directrix: y = -18.00

Input

1
2
4

Output

Latus Rectum = +- 1.00
Vertex: (-1.00,3.00)
Focus : (-1.00,3.25)
Directrix: y = -16.00

Submit your solution

java