Results 1 to 7 of 7

Thread: Slope equation script help

  1. #1
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default Slope equation script help

    Thank you in advance. I just need help doing the 2 cord equation. 1 cord works like a charm

    SCAR Code:
    procedure slope;
    var
    q,slopes,x1,y1,x2,y2,xs,ys,b2s,m1s,slopes,alls : integer;
    b2,m1,slopess,all:extended;
    begin
      q := strtoint(readln('Type 1 or 2 for the following:(1: 1 cord, 2: 2 cord)'));
      if q = 1 then
      begin
        slopes := strtoint(readln('What is the slope of the line?'));
        x1 := strtoint(readln('What is the x cord?'));
        y1 := strtoint(readln('What is the y cord?'));
        m1 := slopes * x1;
        if m1 < 0 then
        begin
          q := 999;
          b2 := y1 + m1;
        end;
        if m1 > 0 then
        begin
          q := 99;
          b2 := y1 - m1;
        end;
        if (q = 999) then
        begin
          writeln('The equation: y = '+inttostr(slopes)+'x '+floattostr(b2));
        end;
        if (q = 99) then
        begin
          writeln('The equation: y = '+inttostr(slopes)+'x '+floattostr(b2));
        end;
      end;
      if q = 2 then
      begin
        x1 := strtoint(readln('What is the first x cord?'));
        y1 := strtoint(readln('What is the first y cord?'));
        x2 := strtoint(readln('What is the second x cord?'));
        y2 := strtoint(readln('What is the second y cord?'));
        ys := y1 - y2;
        xs := x1 - x2;
        all := ys / xs;
        slopess := all;
        m1 := all * x1;
        alls := ys / xs;
        slopes := alls;
        m1s := alls * x1;
        if m1 < 0 then
        begin
          q := 999;
          b2 := y1 + m1;
        end;
        if m1 > 0 then
        begin
          q := 99;
          b2 := y1 - m1;
        end;
        if (q = 999) then
        begin
          writeln('The equation: y = '+floattostr(slopess)+'x '+floattostr(b2));
        end;
        if (q = 99) then
        begin
          writeln('The equation: y = '+floattostr(slopess)+'x '+floattostr(b2));
        end;
        // This part is incase number is a whole number?
        if m1s < 0 then
        begin
          q := 999;
          b2s := y1 + m1s;
        end;
        if m1s > 0 then
        begin
          q := 99;
          b2s := y1 - m1s;
        end;
        if (q = 999) then
        begin
          writeln('The equation: y = '+inttostr(slopes)+'x '+inttostr(b2s));
        end;
        if (q = 99) then
        begin
          writeln('The equation: y = '+inttostr(slopes)+'x '+inttostr(b2s));
        end;
      end;
    end;
    I do visit every 2-6 months

  2. #2
    Join Date
    Dec 2007
    Location
    Williston, ND
    Posts
    3,106
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    Can't you just use excel for this?

    Maybe?
    Proud owner of "Efferator" my totally boted main account!
    "You see, sometimes, science is not a guess" -Xiaobing Zhou (my past physics professor, with heavy Chinese accent)

  3. #3
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    This is just a small part of my script, im making a massive math script to sell to my friends. And to the younger kids who shall get these problems next year.
    I do visit every 2-6 months

  4. #4
    Join Date
    Dec 2007
    Location
    Williston, ND
    Posts
    3,106
    Mentioned
    0 Post(s)
    Quoted
    3 Post(s)

    Default

    lol, so you are just giving them a script to do their homework xD

    Alright, I'm done spamming your thread, I'll let someone come in here and help you
    Proud owner of "Efferator" my totally boted main account!
    "You see, sometimes, science is not a guess" -Xiaobing Zhou (my past physics professor, with heavy Chinese accent)

  5. #5
    Join Date
    Oct 2006
    Location
    Texas
    Posts
    1,450
    Mentioned
    1 Post(s)
    Quoted
    1 Post(s)

    Default

    Slope is that rise over run thing right?
    If so, their is no absolutely need for a script for that shit, All you do is count up to the next point and over to the point and there you go

    Rise
    -
    Run

    if im wrong, then forget this lol.

  6. #6
    Join Date
    Oct 2007
    Location
    http://ushort.us/oqmd65
    Posts
    2,605
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    @Buck - this is for if your given a cordinate(s) + (possibly slope if only 1 cord) you get the equation...

    Edit:Even tho i got no help I changed a few lines and somehow got fixed.
    I do visit every 2-6 months

  7. #7
    Join Date
    May 2007
    Location
    Seattle
    Posts
    1,069
    Mentioned
    0 Post(s)
    Quoted
    1 Post(s)

    Default

    The parent graph for a linear equation is y = mx + b.
    M is your slope AKA rate of change. B is your y-intercept. Y-intercept is the number you start off with on the y axis before graphing.

    The equation for slope is:
    m = (y[1] - y[2]) / (x[1] - x[2])

    All you need to do is replace the variables. This is a really easy thing to make if I'm not mistaken.

    Oh btw, we learned terms at the beginning of this year and when i searched google for "subscripts", they relate it to arrays which I should have made a connection to a longgg time ago!

    EDIT: Oh yeah, to get the y-intercept you find the y value when x is at zero. So do a for statement with the value closest to zero and subtract 1 from the y until its at zero. I could explain an equation for this but its the weekend and Im just tired. You'll get it

    EDIT: Apparently you already get this so just ignore my message XD
    FORMERLY BORN2CODE | Play Internet Games
    http://img147.imageshack.us/img147/2084/sigg.png

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. [Src] Simple quadratic equation solver
    By Freddy1990 in forum Java Help and Tutorials
    Replies: 7
    Last Post: 06-24-2007, 06:53 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •