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

Username:   Password: 
 RegisterRegister   
 Equation of a line (y=Mx+b)
Index -> Programming, Turing -> Turing Submissions
Goto page 1, 2  Next
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Token




PostPosted: Thu Dec 16, 2004 8:45 am   Post subject: Equation of a line (y=Mx+b)

y+Mx+b

Isn't this a term that almost every student from gr 9 all the way to 12 hates! how about when you have to find 4 of these equations to identify a shape! yes it can get to be a very long and drawn out process! so0o I created a program that does it for u Very Happy! yes, very helpfull but you know what would be even more helpfull? a program that finds the reciprocal of the equation... its coming, give me time Razz almost done just working on outputing the information to a .txt file. also it will include finding the midpoint of a line and the distance between any two points on the cartesian plane! well hope this helps Wink !

code:

var x, y, x1, x2, y1, y2, m : real

loop

    put "\n\nTo find the formula of the line"

    put "\nEnter the first coordinate."
    put "X: " ..
    get x1
    put "Y: " ..
    get y1

    put "\nEnter the seccond coordinate."
    put "X: " ..
    get x2
    put "Y: " ..
    get y2


    put "\nSlope for XY"
    put "M=Rise/Run"
    put "M= (Y2-Y1) / (X2-X1)"
    put "M= (", y2, "-", y1, ") / (", x2, "-", x1, ")"
    put "M= (", y2 - y1, ") / (", x2 - x1, ")"

    if y2 - y1 = 0 then
        put "This is a horosontal line."
        put "Y= 0X + ", y1
    elsif x2 - x1 = 0 then
        put "This is a vertical line."
        put "Y= 0X "
    else

        put "M= ", (y2 - y1) / (x2 - x1)


        m := (y2 - y1) / (x2 - x1)
        x := x1
        y := y1

        put "\n Formula of the line"
        put "Y=M X + b"
        put y, "=", m, " (", x, ")+b"
        put y, "=", m * x, "+b"
        put y, "+", m * x, "=", m * x, "-", m * x, "+b"
        put y + (m * x), "= b"
        put "b=", y + (m * x)
        put "Therefore Y=", m, "X +", y + (m * x)
    end if

end loop
Sponsor
Sponsor
Sponsor
sponsor
Neo




PostPosted: Thu Dec 16, 2004 4:41 pm   Post subject: Re: Equation of a line (y=Mx+b)

Token wrote:
y+Mx+b

Isn't this a term that almost every student from gr 9 all the way to 12 hates!


Actually, no.
Andy




PostPosted: Thu Dec 16, 2004 4:43 pm   Post subject: (No subject)

err who uses y=mx+b nymore... Ax+By+C=0 is the way to go... get use to it or ur gona flunk algebra
Tony




PostPosted: Thu Dec 16, 2004 6:15 pm   Post subject: (No subject)

5x5 matrix of heavysides Shocked actually my algebra exam was awesome, I think I aced it... though you never now. I had to reinvent the way you check if vectors are colinear or not because damn it, it's hard to sketch out 4D on paper to check visually

anyways, good idea for the program, but it's buggy.

first set: 1/1
second set: 2/2
the equation is most defenatly not y= x + 2 Confused
Latest from compsci.ca/blog: Tony's programming blog. DWITE - a programming contest.
Martin




PostPosted: Thu Dec 16, 2004 7:23 pm   Post subject: (No subject)

A verticle line should be in the form of x = b
Token




PostPosted: Thu Dec 16, 2004 10:09 pm   Post subject: cool

Hey everyone, thanks for the feedback, this was my first post in compsci and its cool to see how fast everyone responds. umm ya it is a little buggy, usually only with the vertical and horosontal lines tho, my math mark is only a 72 tho so it could be my bad. umm ya at my school (in gr 10) were still using t=Mx+b, its an academic class and my teacher said we'll keep using it all through highschool. I'll look over my notes and see if i can fix up the horosontal and vertical lines if anyone has any ideas why its not working feel free to edit the code other than that thanks for your feedback and its nice working with u guys (and girls, although theyre few and far between)
Pickles




PostPosted: Sun Dec 19, 2004 12:07 am   Post subject: ..

Quote:
err who uses y=mx+b nymore... Ax+By+C=0 is the way to go... get use to it or ur gona flunk algebra


Hooray for G&D.. I love you Ax+By+Cz+D=0 Heart
Andy




PostPosted: Sun Dec 19, 2004 5:19 pm   Post subject: (No subject)

yes, the scalar eqn owns you and me too but shhhhh
Sponsor
Sponsor
Sponsor
sponsor
MihaiG




PostPosted: Mon Dec 20, 2004 6:35 pm   Post subject: (No subject)

im in gr. 9 enriched... and we just finished with y = mx + b and started with Ax+By+C=0 he he he
Andy




PostPosted: Mon Dec 20, 2004 6:39 pm   Post subject: (No subject)

enriched? what school?
MihaiG




PostPosted: Mon Dec 20, 2004 8:46 pm   Post subject: (No subject)

why do you ask.......???
i got to Newmarket High
Pickles




PostPosted: Tue Dec 21, 2004 1:18 am   Post subject: ...

I dont recall ever using Ax+By+C=0 for the equation of a line until this year in G&D (although i know i learned it somewhere along the lines) hmm. Scalar equations of a plane is fun, that and solving the intersection of three planes.. such boring work
Token




PostPosted: Mon Feb 14, 2005 5:06 pm   Post subject: (No subject)

ya well i'm in grade 10 and we just started learning Ax+By+C=0
Mr. T




PostPosted: Mon Feb 14, 2005 7:29 pm   Post subject: (No subject)

my teacher made a calculator prog called solvesys which does all that dirty work for you Wink
ssr




PostPosted: Mon Feb 14, 2005 8:51 pm   Post subject: (No subject)

Token wrote:
ya well i'm in grade 10 and we just started learning Ax+By+C=0

just started?
umm I thought every school in Canda teaches that in gr. 9
ummm 8)
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 2  [ 20 Posts ]
Goto page 1, 2  Next
Jump to:   


Style:  
Search: