area under the curve, JAVA Programming

write a program to find the area under the curvey 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

 

#include 
float
    start_point,            /* GLOBAL VARIABLES */

end_point, total_area; int numtraps; main( ) { void input(void ); float find_area(float a,float b,int n); /* prototype */
print(“AREA UNDER A CURVE”); input( ); total_area = find_area(start_point, end_point, numtraps); printf(“TOTAL AREA = %f”, total_area); } void input(void ) { printf(“\n Enter lower limit:”); scanf(“%f”, &start_point); printf(“Enter upper limit:”); scanf(“%f”, &end_point); printf(“Enter number of trapezoids:”); scanf(“%d”, &numtraps); } float find_area(float a, float b, int n) { float base , lower, h1, h2; /* LOCAL VARIABLES */
float function_x(float x); /* prototype */
float trap_area(float h1,float h2,float base );/*prototype*/
base = (b-1)/n; lower = a; for (lower =a; lower <= b-base ; lower = lower + base ) { h1 = function_x(lower); h1 = function_x(lower + base ); total_area += trap_area(h1, h2, base ); } return (total_area); float trap_area(float height_1,float height_2,float base ) { float area; /* LOCAL VARIABLE */
area = 0.5 * (height_1 + height_2) * base ; return (area); } float function_x(float x) { /* F(X) = X * X + 1 */
return (x*x + 1); } Output AREA UNDER A CURVE Enter lower limit: 0 Enter upper limit: 3 Enter number of trapezoids: 30 TOTAL AREA = 12.005000 AREA UNDER A CURVE Enter lower limit: 0 Enter upper limit: 3 Enter number of trapezoids: 100 TOTAL AREA = 12.000438

Posted Date: 9/1/2012 6:07:35 AM | Location : United States







Related Discussions:- area under the curve, Assignment Help, Ask Question on area under the curve, Get Answer, Expert's Help, area under the curve Discussions

Write discussion on area under the curve
Your posts are moderated
Related Questions
What are application softwares? List down the names of three application software's. Definition: Application Software are in which software then can interact directory along

Conway's Game of Life is a "cellular automaton" that is played on a 2D grid (array) of cells. At the start of the game, an initial configuration is set up in which a number of cell

How instant messaging works? Write the steps involved in this process? The Instant Messaging services available permit us to manage a list of people (contacts) that we interact

The following set of short questions will focus on getting you familiar with JavaScript functions. All functions and testing should appear in a single XHTML 1.0 Strict page. All

Android and Universal iOS, Multipurpose Testing App Universal iOS and Android, versatile Testing App Based on Phonegap with the subsequent main features * Support single answ

list The Java Class Library? Java holds an extensive library of pre-written classes you can use in your programs. These classes are separated into groups known as packages. Th


Use a FOR loop and give me the largest number divisible by 7 11 13 17 use the number from 1 to 10000 (or even 100000)

Notice that each row now has the type of customer and the additional data needed. calculateBill remains the same in Customer.  However, the calculateBill in Corporate will add a

This is a two part project, one in Alice, and another in Java. You can either zip the files together as one and upload the single zip file, OR upload the separate files. If you dec