Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 how to find slop ?
Index -> Programming, Java -> Java Help
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Bhai




PostPosted: Mon Apr 09, 2007 6:15 pm   Post subject: how to find slop ?

Hey guys i am suppose to find slope of the point that are entered in the program and i have no clue how to can some one help please
I attached the program i have finished up till here

I am suppose to :

# After all data points are entered you will then calculate the slope for each successive pair of points using the formula for slope of a line (using the current data point and the previous data point). This is to be done for all data points except for the first data point (for obvious reasons).

# Next calculate the average of these slopes to get an approximate slope value for this line, the minimum slope of any two points, the maximum slope of any two points and the variance (difference between the minimum and the maximum).

if any gets it plz upload it asap thank you



asn4.1.java
 Description:

Download
 Filename:  asn4.1.java
 Filesize:  2.71 KB
 Downloaded:  140 Time(s)

Sponsor
Sponsor
Sponsor
sponsor
Clayton




PostPosted: Mon Apr 09, 2007 6:40 pm   Post subject: RE:how to find slop ?

We can help you do your work, however, we are not going to hand it to you on a silver platter. A good place to start is, do you know the equation of a line? Do you know how to find the slope of two points on paper?
Bhai




PostPosted: Mon Apr 09, 2007 8:40 pm   Post subject: Re: how to find slop ?

hey man i know u wouldnt want to do someones work i would either but i just dono how to start
like i dont know how to actually find the slope in java i know it (y2-y2)/(x2-x1)
if you could just help me get started on how to do it in java that would be well appreaciated
Clayton




PostPosted: Mon Apr 09, 2007 8:45 pm   Post subject: RE:how to find slop ?

You more or less just did it Wink
haskell




PostPosted: Mon Apr 09, 2007 8:49 pm   Post subject: RE:how to find slop ?

Are you also going to be finding the slope of curved lines as well?

If not, your programs practical use takes a major hit.
Bhai




PostPosted: Mon Apr 09, 2007 8:57 pm   Post subject: Re: how to find slop ?

no just a slope i just dono how to get started for the line
The REAL Man




PostPosted: Wed Apr 11, 2007 9:21 am   Post subject: Re: how to find slop ?

if you are trying to get the slope of all the lines entered, use a for loop to calculate the slope for each line.

Java:

for (a = 0 ; a < numberOfLines ; a++)
{
      slope [a] = (y[a+1]-y[a]) / (x[a+1]-x[a])
}


then you should end up with an array of the slops. i havent tested this yet so it might be wrong. hope it helps
wtd




PostPosted: Wed Apr 11, 2007 2:05 pm   Post subject: RE:how to find slop ?

How to find slop? Just head to your nearest school cafeteria. They serve it up every day.
Sponsor
Sponsor
Sponsor
sponsor
FileFantasy




PostPosted: Sat Apr 14, 2007 8:58 pm   Post subject: RE:how to find slop ?

Here's what you do:

- Make a double[] for array of slopes, this array's length should be 1 less than # of x-axis.

- for every point starting from the second one, do y2-y1/x2-x1, where y2,x2 is current point, and y1,x1 is the previous point, store the result in the slope array

- now for every slope, just print it out or something
ericfourfour




PostPosted: Sun Apr 15, 2007 12:13 am   Post subject: Re: RE:how to find slop ?

FileFantasy @ Sat Apr 14, 2007 8:58 pm wrote:
y2-y1/x2-x1

Order of operations. m = (y2 - y1) / (x2 - x1)

Or if you are given a coordinate, y-intercept and need to solve for m:
code:
y = mx + b
y - b = mx
m = (y - b) / x


To calculate the average of the slope:
code:
slope av = slope sum / slope amount


To find the minimum:
code:
minimum = any slope
for each slope
    minimum = min (lowest, slope)


To find the maximum:
code:
maximum = any slope
for each slope
    maximum = max (highest, slope)
FileFantasy




PostPosted: Sun Apr 15, 2007 8:47 pm   Post subject: RE:how to find slop ?

By "min (lowest, slope)" and "max (highest, slope)", he means to use the respective methods in the Math class.
Bhai




PostPosted: Wed Apr 18, 2007 4:33 pm   Post subject: Re: how to find slop[e] ?

Hey Thanks for the help guys and i finished the program
ericfourfour




PostPosted: Wed Apr 18, 2007 6:24 pm   Post subject: RE:how to find slop ?

I just realized this, but in the pseudo code I provided, please replace lowest and highest with minimum and maximum.
Display posts from previous:   
   Index -> Programming, Java -> Java Help
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 13 Posts ]
Jump to:   


Style:  
Search: