Adblock breaks this site

Need help (Do it for lulz)

Discussion in 'Scar/Simba Help' started by Xjaa, Jan 7, 2008.

  1. Xjaa

    Xjaa Penguin
    $100 USD Donor

    Joined:
    Jan 21, 2007
    Posts:
    3,248
    Referrals:
    2
    Sythe Gold:
    0
    Lawrence Potamus
    Need help (Do it for lulz)

    Code:
    program CubicCalculator;
    
    var
          l: Integer;
        w: Integer;
      h: Integer;
    k: Boolean;
    begin
    
          l:= 1; //Enter length of cube here
        w:= 2;  //Enter Width of cube here
      h:= 3;   //Enter Height of cube here
    k:= True; //Don't Fuck with this
    if (k = True) then
     begin
    WriteLn('l* w * h');
    
    end;
    end.
    I designed this script to solve the algebraic equation V= l*w*h

    As far as I can tell from looking at it I made an error stating a multiplication, any advice?
     
  2. Town

    Town Grand Master
    Scar Programmers

    Joined:
    Jan 21, 2007
    Posts:
    3,776
    Referrals:
    3
    Sythe Gold:
    5
    Need help (Do it for lulz)

    Code:
    const
            l= 1; //Enter length of cube here
        w= 2;  //Enter Width of cube here
      h= 3;   //Enter Height of cube here
    k= True; //Don't Fuck with this
    begin
    if (k) then WriteLn(IntToStr(l* w * h));
    end.
     
  3. Xjaa

    Xjaa Penguin
    $100 USD Donor

    Joined:
    Jan 21, 2007
    Posts:
    3,248
    Referrals:
    2
    Sythe Gold:
    0
    Lawrence Potamus
    Need help (Do it for lulz)

    I am stating as variables because I want to be able to replace the identifiers with other numbers.
    you stated them as constants I believe.
     
  4. Town

    Town Grand Master
    Scar Programmers

    Joined:
    Jan 21, 2007
    Posts:
    3,776
    Referrals:
    3
    Sythe Gold:
    5
    Need help (Do it for lulz)

    You can change that back to how you had it then. Just remember you can't do math with strings.
     
  5. Xjaa

    Xjaa Penguin
    $100 USD Donor

    Joined:
    Jan 21, 2007
    Posts:
    3,248
    Referrals:
    2
    Sythe Gold:
    0
    Lawrence Potamus
    Need help (Do it for lulz)

    Code:
    program CubicCalculator;
    
    const
    
          l= 1; //Enter length of cube here
        w= 2;  //Enter Width of cube here
      h= 3;   //Enter Height of cube here
    k= True; //Don't Fuck with this
    begin
    if (k = True) then
     begin
    WriteLn('l * w * h');
    
    end;
    end.

    Alright, here it is with constants, but Instead of getting "6" as the answer I just get "l * w * h" ,

    And I'm not using strings...
     
  6. ProphesyOfWolf

    ProphesyOfWolf Member

    Joined:
    Dec 6, 2007
    Posts:
    85
    Referrals:
    0
    Sythe Gold:
    0
    Need help (Do it for lulz)

    You are, though. Anything inside of ' ' will be a string.. You need to turn the result of the algebraic equation into a string, using IntToStr.. For instance.. You'd rewrite
    Code:
    WriteLn('l * w * h');
    to
    Code:
    WriteLn('' +IntToStr(l * w * h));
    By doing '' at the beginning, it's leaving room for text, and the + before IntToStr adds in the string created from the math done by l*w*h. Lemme know if it still gives you problems..

    NOTE: IntToStr (integer to string) turns an integer into a string. Just wanted to point that out to anyone who didn't get that from my examples..
     
  7. Xjaa

    Xjaa Penguin
    $100 USD Donor

    Joined:
    Jan 21, 2007
    Posts:
    3,248
    Referrals:
    2
    Sythe Gold:
    0
    Lawrence Potamus
    Need help (Do it for lulz)

    Code:
    program CubicCalculator;
    
    const
    
            Length= 1;  //Enter length of cube here
          Width= 2;   //Enter Width of cube here
       Height= 3;   //Enter Height of cube here
     k= True;     //Don't Fuck with this
    begin
     if (k = True) then
       begin
    
         WriteLn('' +IntToStr(Length * Width * Height));
       end;
    end.
    Invalid number of parameters in script in line 13.
    I am using constants not integers will that matter?
     
  8. GMK

    GMK Forum Addict

    Joined:
    Aug 2, 2007
    Posts:
    395
    Referrals:
    0
    Sythe Gold:
    0
    Need help (Do it for lulz)

    put the : back and it will work. i think!
     
  9. Town

    Town Grand Master
    Scar Programmers

    Joined:
    Jan 21, 2007
    Posts:
    3,776
    Referrals:
    3
    Sythe Gold:
    5
    Need help (Do it for lulz)

    Choose a different variable name, Length is the name of a procedure.
     
  10. Xjaa

    Xjaa Penguin
    $100 USD Donor

    Joined:
    Jan 21, 2007
    Posts:
    3,248
    Referrals:
    2
    Sythe Gold:
    0
    Lawrence Potamus
    Need help (Do it for lulz)

    That was the problem, thanks guys.
     
< option chooser | i need help >


 
 
Adblock breaks this site