Close Menu
    DevStackTipsDevStackTips
    • Home
    • News & Updates
      1. Tech & Work
      2. View All

      CodeSOD: A Unique Way to Primary Key

      July 22, 2025

      BrowserStack launches Figma plugin for detecting accessibility issues in design phase

      July 22, 2025

      Parasoft brings agentic AI to service virtualization in latest release

      July 22, 2025

      Node.js vs. Python for Backend: 7 Reasons C-Level Leaders Choose Node.js Talent

      July 21, 2025

      The best CRM software with email marketing in 2025: Expert tested and reviewed

      July 22, 2025

      This multi-port car charger can power 4 gadgets at once – and it’s surprisingly cheap

      July 22, 2025

      I’m a wearables editor and here are the 7 Pixel Watch 4 rumors I’m most curious about

      July 22, 2025

      8 ways I quickly leveled up my Linux skills – and you can too

      July 22, 2025
    • Development
      1. Algorithms & Data Structures
      2. Artificial Intelligence
      3. Back-End Development
      4. Databases
      5. Front-End Development
      6. Libraries & Frameworks
      7. Machine Learning
      8. Security
      9. Software Engineering
      10. Tools & IDEs
      11. Web Design
      12. Web Development
      13. Web Security
      14. Programming Languages
        • PHP
        • JavaScript
      Featured

      The Intersection of Agile and Accessibility – A Series on Designing for Everyone

      July 22, 2025
      Recent

      The Intersection of Agile and Accessibility – A Series on Designing for Everyone

      July 22, 2025

      Zero Trust & Cybersecurity Mesh: Your Org’s Survival Guide

      July 22, 2025

      Execute Ping Commands and Get Back Structured Data in PHP

      July 22, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      A Tomb Raider composer has been jailed — His legacy overshadowed by $75k+ in loan fraud

      July 22, 2025
      Recent

      A Tomb Raider composer has been jailed — His legacy overshadowed by $75k+ in loan fraud

      July 22, 2025

      “I don’t think I changed his mind” — NVIDIA CEO comments on H20 AI GPU sales resuming in China following a meeting with President Trump

      July 22, 2025

      Galaxy Z Fold 7 review: Six years later — Samsung finally cracks the foldable code

      July 22, 2025
    • Learning Resources
      • Books
      • Cheatsheets
      • Tutorials & Guides
    Home»News & Updates»CodeSOD: A Steady Ship

    CodeSOD: A Steady Ship

    April 10, 2025
    CodeSOD: A Steady Ship

    You know what definitely never changes? Shipping prices. Famously static, despite all economic conditions and the same across all shipping providers. It doesn’t matter where you’re shipping from, or to, you know exactly what the price will be to ship that package at all times.

    Wait, what? You don’t think that’s true? It must be true, because Chris sent us this function, which calculates shipping prices, and it couldn’t be wrong, could it?

    public double getShippingCharge(String shippingType, bool saturday, double subTot)
    {
        double shCharge = 0.00;
        if(shippingType.Equals("Ground"))
        {
            if(subTot <= 29.99 && subTot > 0)
            {
                shCharge = 4.95;
            }
            else if(subTot <= 99.99 && subTot > 29.99)
            {
                shCharge = 7.95;
            }
            else if(subTot <= 299.99 && subTot > 99.99)
            {
                shCharge = 9.95;
            }
            else if(subTot > 299.99)
            {
                shCharge = subTot * .05;
            }              
        }
        else if(shippingType.Equals("Two-Day"))
        {
            if(subTot <= 29.99 && subTot > 0)
            {
                shCharge = 14.95;
            }
            else if(subTot <= 99.99 && subTot > 29.99)
            {
                shCharge = 19.95;
            }
            else if(subTot <= 299.99 && subTot > 99.99)
            {
                shCharge = 29.95;
            }
            else if(subTot > 299.99)
            {
                shCharge = subTot * .10;
            }              
        }
        else if(shippingType.Equals("Next Day"))
        {
            if(subTot <= 29.99 && subTot > 0)
            {
                shCharge = 24.95;
            }
            else if(subTot <= 99.99 && subTot > 29.99)
            {
                shCharge = 34.95;
            }
            else if(subTot <= 299.99 && subTot > 99.99)
            {
                shCharge = 44.95;
            }
            else if(subTot > 299.99)
            {
                shCharge = subTot * .15;
            }              
        }
        else if(shippingType.Equals("Next Day a.m."))
        {
            if(subTot <= 29.99 && subTot > 0)
            {
                shCharge = 29.95;
            }
            else if(subTot <= 99.99 && subTot > 29.99)
            {
                shCharge = 39.95;
            }
            else if(subTot <= 299.99 && subTot > 99.99)
            {
                shCharge = 49.95;
            }
            else if(subTot > 299.99)
            {
                shCharge = subTot * .20;
            }              
        }                                      
        return shCharge;
    }
    

    Next you’re going to tell me that passing the shipping types around as stringly typed data instead of enums is a mistake, too!

    [Advertisement]
    Utilize BuildMaster to release your software with confidence, at the pace your business demands. Download today!

    Source: Read More 

    Facebook Twitter Reddit Email Copy Link
    Previous Articleautoenv provides directory based environments
    Next Article 8 Best Free and Open Source Terminal-Based Flashcard Tools

    Related Posts

    News & Updates

    The best CRM software with email marketing in 2025: Expert tested and reviewed

    July 22, 2025
    News & Updates

    This multi-port car charger can power 4 gadgets at once – and it’s surprisingly cheap

    July 22, 2025
    Leave A Reply Cancel Reply

    For security, use of Google's reCAPTCHA service is required which is subject to the Google Privacy Policy and Terms of Use.

    Continue Reading

    CVE-2024-12718 – Python Tarfile Filter File Metadata and Permission Modification Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-53366 – Apache MCP Model Context Protocol Denial of Service

    Common Vulnerabilities and Exposures (CVEs)

    CVE-2025-5620 – D-Link DIR-816 OS Command Injection Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    UPERFECT Unify B5 Portable Monitor 1080P Display Review

    Linux

    Highlights

    News & Updates

    I can’t believe we’re already getting a sequel to one of the best survival games ever, and I doubly can’t believe how much it’ll cost

    June 10, 2025

    During the Xbox Games Showcase 2025, Obsidian Entertainment shocked me by unveiling Grounded 2, the…

    CVE-2025-7420 – Tenda O3V2 HTTPd Stack-Based Buffer Overflow

    July 10, 2025

    CVE-2025-6859 – SourceCodester Best Salon Management System SQL Injection Vulnerability

    June 29, 2025

    AI Workforce: using AI and Drones to simplify infrastructure inspections

    April 3, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

    Type above and press Enter to search. Press Esc to cancel.