Page 1 of 4 123 ... LastLast
Results 1 to 10 of 32

Thread: Would like to use a script to input Math functions...

  1. #1
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default Would like to use a script to input Math functions...

    Hello everyone, anyone...

    I have a math formula that I need to test with different variables. I need to test it 100 times with each variable, and I have 3 variables.

    what I would like is something (php?) where it asks me for the 3 variables in a text box, then when I hit the submit button, it enters the numbers I have input and runs the calculation, and displays the result.

    The formula is this:

    Math.floor(
    ((B * 2) + Math.ceiling(H/4) * L)/100 +5 )

    Now, perhaps my write out is wrong (never was good at order of operations, LOL

    I need B multiplied by 2 first, then H divided by 4 (rounded up) then those 2 added together, that total multiplied by L, that total divided by 100 and finally that total added to 5, with the whole thing rounded down.

    Anyone can help with this?

    Thanks a TON!

    BLiZZ
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  2. #2
    Join Date
    Dec 2004
    Location
    UK
    Posts
    2,358
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default

    Quote Originally Posted by BLiZZaRD
    Math.floor(
    ((B * 2) + Math.ceiling(H/4) * L)/100 +5 )

    Now, perhaps my write out is wrong (never was good at order of operations, LOL
    As far as arithmetic is concerned, 'multiplicative' operations (multiply, divide, modulus) take precedence over 'additive' operations (add, subtract).

    I need B multiplied by 2 first, then H divided by 4 (rounded up) then those 2 added together, that total multiplied by L, that total divided by 100 and finally that total added to 5, with the whole thing rounded down.
    Your expression is almost correct: multiplication by L will occur in the wrong order.

    Code:
    floor((B * 2 + ceil(H / 4)) * L / 100 + 5)
    Exactly how to implement that depends on the language you want to use to do it.

    Anyone can help with this?
    Well first, where do you want to perform this, and how do you want to display the result? Server-side or client-side. The result in an input element, or the document itself?

    Mike

  3. #3
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Thanks for the reply Mike!

    As far as how, I really don't care. Which ever is the easiest I guess. I was thinking of php, but I don't know if it can do it. If it isn't html I can't do much with it. I can figure out some php and some perl, but that is about it.

    I have a code for a similar formula that was written in C+, but I don't know how to put those kind of things on my computer to execute them.

    (Now I feel like a putz)

    What I was looking for is something with 3 boxes, one for each variable, where I can enter numbers, and a button to click when I have entered all three. Then the script/program/whatever would run the formula, and display the results, same page/screen, new page/screen doesn't matter.

    Anything would help really, anything that keeps me from doing it on paper, LOL

    I have a website, so I have access to the server, if it is needed, and I have a pretty powerful computer at home if it needs to be run from the cpu instead of online. I have Win XP and Fedora Core 3.

    The options are pretty open.

    Thanks again!
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  4. #4
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Here is the C#/Java code I was talking about:

    Code:
       /** 
         * Calculates any stat Hidden Values
         */
       private double CalculateAbility( double effortValue, double baseValue,
            double individualValue, double level, double personality )
       {
            double quarterEffort = Math.Floor( effortValue / 4 );
            double doubleBase = baseValue * 2;
            double levelValue = 
                    ( doubleBase + individualValue + quarterEffort ) * level;
            double levelPercentage = levelValue / 100;
            double personalityValue = 
                    Math.Floor( ( levelPercentage + 5 ) * personality );
    
            return personalityValue;
       }
    As you can see it is pretty close to what I need done, it is using this formula:

    Code:
          Stat = Math.Floor(
             (( BaseStat * 2 + I + Math.Floor( E/4 ) ) * L/100 + 5 ) * P
          )
    Again, I can modify this to my formula, but I don't know how to impliment and execute it... would I place it on a web page and browse to it? Do I need an external program??


    (I need to take some classes I think, LOL)
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  5. #5
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    That's Java.
    This is very unhelpful, due to Java's flexibility This function could be just as easily used in a Java Server Page (JSP), a servlet (similar to a CGI program), or an applet (I take it you know what an applet is ). Where would you prefer it? If one of the former two, do you have an appropriate servlet container installed?
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  6. #6
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Applets are fine with me! I at least DO know what those are.

    as far as servlet containers, I have.. uhh... some things... hang on... let me blow the dust off...

    Tomcat... thats here on my HD... and a Sun J2EE or something like that, is that what you mean?

    I have Netbeans too... LOL I have never used them, but they are here!
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  7. #7
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    Code:
    <%
    // ability_calculator.jsp
       double CalculateAbility( double effortValue, double baseValue,
            double individualValue, double level, double personality )
       {
            double quarterEffort = Math.Floor( effortValue / 4 );
            double doubleBase = baseValue * 2;
            double levelValue = 
                    ( doubleBase + individualValue + quarterEffort ) * level;
            double levelPercentage = levelValue / 100;
            double personalityValue = 
                    Math.Floor( ( levelPercentage + 5 ) * personality );
    
            return personalityValue;
       }
    %>
    Personality value for values given:  <%= CalculateAbility(
      Double.parseDouble(request.getParameter("eff")),
      Double.parseDouble(request.getParameter("bas")),
      Double.parseDouble(request.getParameter("ind")),
      Double.parseDouble(request.getParameter("lev")),
      Double.parseDouble(request.getParameter("per"))
    ) %>
    That will do it. Pass eff, bas, ind, lev and per as request variables to the script. Use GET or POST, it doesn't matter.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

  8. #8
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    Thanks Twey!

    I will give it a try... here... I don't know what I am doing and will probably get errors or something, LOL..

    Now.. where to stick this...
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  9. #9
    Join Date
    Aug 2005
    Location
    Other Side of My Monitor
    Posts
    3,494
    Thanks
    5
    Thanked 105 Times in 104 Posts
    Blog Entries
    1

    Default

    AHHHH! Nothing!

    I started Tomcat (even got the latest 5.x) but don't know where to stick the script...

    LOL, told you I never used it before!

    But there is Ol' Tomcat... see the icon in my tray? Gotta be something GUI-ish around here.......
    {CWoT - Riddle } {Freelance Copywriter} {Learn to Write}
    Follow Me on Twitter: @InkingHubris
    PHP Code:
    $result mysql_query("SELECT finger FROM hand WHERE id=3");
    echo 
    $result

  10. #10
    Join Date
    Jun 2005
    Location
    英国
    Posts
    11,876
    Thanks
    1
    Thanked 180 Times in 172 Posts
    Blog Entries
    2

    Default

    see the icon in my tray?
    No
    http://www.moreservlets.com/Using-Tomcat-4.html
    Tomcat 5 probably isn't so different.
    Twey | I understand English | 日本語が分かります | mi jimpe fi le jbobau | mi esperanton komprenas | je comprends français | entiendo español | tôi ít hiểu tiếng Việt | ich verstehe ein bisschen Deutsch | beware XHTML | common coding mistakes | tutorials | various stuff | argh PHP!

Bookmarks

Posting Permissions

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