CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 5 of 5
  1. #1
    Join Date
    Nov 2013

    Online quote scipt

    I am trying to build or find an on-line instant quote calculator

    the formula I am trying to calculate is

    49 for the first 35 items

    0.85 each item thereafter

    user inputs total amount of items eg 400 items

    400 items - 35 = 365

    365 * 0.85 = 310.25

    310.25 + 49 = 359.25

    Total Price 359.25

    Then the total price 359.25 / 400 to give the price per item 0.89 (to two decimal places)

    I've found several on-line calculator builders but nothing that can handle this sort of variables.

    This script is the closest I have got but my maths is terrible and I cant seem to edit the code correctly http://www.dynamicdrive.com/forums/s...ote-calculator

  2. #2
    Join Date
    Nov 2013

    Re: Online quote scipt

    just for the record.. I am here to learn.. please just push me in the right direction, not asking for the solution here.. (just experienced abuse on stackoverflow lol)

    everyones thinks it... noobs! who'd have em'
    Last edited by MBCUK; November 25th, 2013 at 01:45 PM.

  3. #3
    Join Date
    Nov 2013

    Re: Online quote scipt

    I have this as a starting point


  4. #4
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002

    Re: Online quote scipt

    You already have the math completely done in the first post. All you have to do is get the input now.

    Start with a simple prompt window.

    Now get the return and do the math.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  5. #5
    Join Date
    Jun 2009

    Re: Online quote scipt

    There's no harm in breaking the problem into simple lines of code, not least so it makes it easier for someone else to manage.
    var minimum = 35,
        output = 0,
        input  = prompt("How many items?");
    if ( input<=minimum ) {
        output = 49;   // first 35 items are minimum 49
    else {
        output  = input - minimum;
        output  = output * 0.85;  // 85p per additional item above minimum order
        output += 49;
    alert("Total = "+output.toFixed(2)+", Per Item = "+(output/input).toFixed(2));
    Did you deliberately want to round down though because the per item in your example is actually 0.898125 which to 2 decimal places should be 0.90?

Posting Permissions

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

Windows Mobile Development Center

Click Here to Expand Forum to Full Width

On-Demand Webinars (sponsored)

We have made updates to our Privacy Policy to reflect the implementation of the General Data Protection Regulation.