Monday, September 3, 2012

Area Under Curve :: Aspiration 2020 :: question number 3

Area Under Curve :: Aspiration 2020 :: question number 3

Area Under Curve

Write a program to find the area under the curve y = f(x) between x = a and x = b, integrate y = f(x) between the limits of a and b.
The area under a curve between two points can be found by doing a definite integral between the two points.

Instructions to work with Open PBT Client:

  1. Specify the work directory path in the 'Work Directory Path' field. The path should correspond to your solution project directory.
  2. Download the support files by clicking the Get Dev Files.
  3. You will find the following three folders:
    • bin
    • src
    • lib
    in your work directory.
  4. Code the solution in  . java file inside the src folder
  5. All required files will be downloaded to your work directory. Creating additional files is strongly discouraged.

The Prototype of the Function is :

public double getAreaUnderCurve(Term[] equation, int limit1, int limit2)
  • Where equation represents number of Term in a equation with x_pow and coeff of X
  • Where limit1 and limit2 are the 2 given points to find the area.
  • The function getAreaUnderCurve() return the area of type double corrected to 4 decimal places.(eg : 5.2704. )

Example 1

Input :
    Term[] equation = x + 3(x^2);     int limit1 = 4;     int limit2 = 8;
    where, Term[] equation = new Term[2]
    func[0] = new Term(1,1)
    func[1] = new Term(2,3)
Output :
The function getAreaUnderCurve() returns 472.0.
Explanation :

Example 2

Input :
    Term[] equation = x;     int limit1 = 1;     int limit2 = 1;
Output :
The function getAreaUnderCurve() returns 0.0

Example 3

Input :
    Term[] equation = x;     int limit1 = 2;     int limit2 = 1;
Output :
The function getAreaUnderCurve() returns 1.5

For Java solutions

Package Name - test.areaundercurve
File Name - AreaUnderCurve.java
Class Name - AreaUnderCurve
Function Name - public double getAreaUnderCurve(Term[] equation, int limit1, int limit2)

General Instructions

    

The package names, class names, method signatures are to be used as mentioned in the problem statement. Do not use your own names or change the method signatures and fields. You can add any number of additional methods.

    

The function(s) defined above would be the only functions that would be tested. If you add a main() function for your own testing, that would not be tested.

    

Command line options for the main() function are not supported currently.



--
Hackerx Sasi
Don't ever give up.
Even when it seems impossible,
Something will always
pull you through.
The hardest times get even
worse when you lose hope.
As long as you believe you can do it, You can.

But When you give up,
You lose !
I DONT GIVE UP.....!!!


In three words I can sum up everything I've learned about life - it goes on......
with regards
prem sasi kumar arivukalanjiam

No comments:

Post a Comment