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

      The Psychology Of Color In UX Design And Digital Products

      August 15, 2025

      This week in AI dev tools: Claude Sonnet 4’s larger context window, ChatGPT updates, and more (August 15, 2025)

      August 15, 2025

      Sentry launches MCP monitoring tool

      August 14, 2025

      10 Benefits of Hiring a React.js Development Company (2025–2026 Edition)

      August 13, 2025

      Your smart home device just got a performance and security boost for free

      August 18, 2025

      Ultrahuman brings advanced cycle and ovulation tracking to its smart ring

      August 18, 2025

      DistroWatch Weekly, Issue 1135

      August 17, 2025

      14 secret phone codes that unlock hidden features on your Android and iPhone

      August 17, 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

      Air Quality Prediction System using Python ML

      August 17, 2025
      Recent

      Air Quality Prediction System using Python ML

      August 17, 2025

      AI’s Hidden Thirst: The Water Behind Tech

      August 16, 2025

      Minesweeper game in 100 lines of pure JavaScript – easy tutorial

      August 16, 2025
    • Operating Systems
      1. Windows
      2. Linux
      3. macOS
      Featured

      DistroWatch Weekly, Issue 1135

      August 17, 2025
      Recent

      DistroWatch Weekly, Issue 1135

      August 17, 2025

      Ubuntu’s New “Dangerous” Daily Builds – What Are They?

      August 17, 2025

      gofmt – formats Go programs

      August 17, 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

    Your smart home device just got a performance and security boost for free

    August 18, 2025
    News & Updates

    Ultrahuman brings advanced cycle and ovulation tracking to its smart ring

    August 18, 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-2025-6865 – DaiCuo Cross-Site Request Forgery (CSRF) Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Sednit Espionage Group Attacking Air-Gapped Networks

    Development

    Tales of the Shire Hits Xbox: Microsoft Brings Hobbit Life Sim to Middle-earth Fans This Fall

    Operating Systems

    CVE-2025-5600 – TOTOLINK EX1200T Stack-Based Buffer Overflow Vulnerability

    Common Vulnerabilities and Exposures (CVEs)

    Highlights

    Development

    Canvas App Components: A Crash Course for Power Apps Developers

    May 17, 2025

    If you have experience in traditional software development, low-code tools may feel a bit sparse…

    mpv-mpris – plugin for mpv

    July 22, 2025

    The 6 Linux distros I recommend most for gaming in 2025 – including my favorite

    April 15, 2025

    CVE-2025-5660 – PHPGurukul Complaint Management System SQL Injection Vulnerability

    June 5, 2025
    © DevStackTips 2025. All rights reserved.
    • Contact
    • Privacy Policy

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