Delivery charge program
CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 2 of 2

Thread: Delivery charge program

  1. #1
    Join Date
    May 2007
    Posts
    9

    Delivery charge program

    It's just a work in progress at the moment, but I'd appreciate some help, again.

    I'm writing a program for a delivery service where there are following conditions.

    For orders worth less than 25 the delivery charge is 3.00.
    Orders worth at least 25 but less than 100 are delivered free.
    Orders worth 100 or more are delivered free and in addition the
    customer receives a free gift. I prompt the user to enter the order value, and tell him/her which band he comes under.

    This is what I have so far, and it doesn't seem to be it, evidently.

    Code:
    <html> 
    <body> 
    <script type='text/javascript'> 
    // A delivery charge program 
    var ordervalue; // how much the order is worth ordervalue = window.prompt ('How much is the order worth in Pounds Sterling?','');  
    str='The value of your order is ' + ordervalue; 
    if (ordervalue <= 25) 
    str='Your delivery will cost 3 as your order value is ' + ordervalue'; 
    if (ordervalue > 25 &&  ordervalue < 100)
    {  str='Your delivery is free as your order value is ' + ordervalue';  
    }else 
    str='You will receive a free gift and delivery is free as your order value is ' + ordervalue; 
    alert(str); // to output a result to see it is works! 
    </script> 
    </body> </html>
    I'd love some help, please

  2. #2
    PeejAvery's Avatar
    PeejAvery is offline Super Moderator Power Poster
    Join Date
    May 2002
    Posts
    10,867

    Re: Delivery charge program

    This is JavaScript so I will have it moved to the client-side scripting forum. Concerning your problem...you had two quotes out of place and you need to work on brackets around if and else statements. You can see the extra quote at the end of...

    Code:
    value is ' + ordervalue';
    I have cleaned up the brackets and fixed the quotes.

    Code:
    <script type='text/javascript'> 
    // A delivery charge program 
    var ordervalue; // how much the order is worth ordervalue = window.prompt ('How much is the order worth in Pounds Sterling?','');  
    str = 'The value of your order is ' + ordervalue; 
    if(ordervalue <= 25){str = 'Your delivery will cost 3 as your order value is ' + ordervalue;}
    if(ordervalue > 25 && ordervalue < 100){str = 'Your delivery is free as your order value is ' + ordervalue;}
    else{str = 'You will receive a free gift and delivery is free as your order value is ' + ordervalue;}
    alert(str); // to output a result to see it is works! 
    </script>
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

Posting Permissions

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


Azure Activities Information Page

Windows Mobile Development Center


Click Here to Expand Forum to Full Width

This is a CodeGuru survey question.


Featured


HTML5 Development Center