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

      Sunshine And March Vibes (2025 Wallpapers Edition)

      June 2, 2025

      The Case For Minimal WordPress Setups: A Contrarian View On Theme Frameworks

      June 2, 2025

      How To Fix Largest Contentful Paint Issues With Subpart Analysis

      June 2, 2025

      How To Prevent WordPress SQL Injection Attacks

      June 2, 2025

      How Red Hat just quietly, radically transformed enterprise server Linux

      June 2, 2025

      OpenAI wants ChatGPT to be your ‘super assistant’ – what that means

      June 2, 2025

      The best Linux VPNs of 2025: Expert tested and reviewed

      June 2, 2025

      One of my favorite gaming PCs is 60% off right now

      June 2, 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

      `document.currentScript` is more useful than I thought.

      June 2, 2025
      Recent

      `document.currentScript` is more useful than I thought.

      June 2, 2025

      Adobe Sensei and GenAI in Practice for Enterprise CMS

      June 2, 2025

      Over The Air Updates for React Native Apps

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

      You can now open ChatGPT on Windows 11 with Win+C (if you change the Settings)

      June 2, 2025
      Recent

      You can now open ChatGPT on Windows 11 with Win+C (if you change the Settings)

      June 2, 2025

      Microsoft says Copilot can use location to change Outlook’s UI on Android

      June 2, 2025

      TempoMail — Command Line Temporary Email in Linux

      June 2, 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

    How Red Hat just quietly, radically transformed enterprise server Linux

    June 2, 2025
    News & Updates

    OpenAI wants ChatGPT to be your ‘super assistant’ – what that means

    June 2, 2025
    Leave A Reply Cancel Reply

    Continue Reading

    Get the PDF Tool That Makes Your Work Easy for Just $30 Through 6/17

    Development

    Huawei Introduces Pangu Ultra MoE: A 718B-Parameter Sparse Language Model Trained Efficiently on Ascend NPUs Using Simulation-Driven Architecture and System-Level Optimization

    Machine Learning

    My favorite ChatGPT feature just got way more powerful

    News & Updates

    Terraform Labs Co-Founder Kwon Faces U.S. Court Over $40 Billion Fraud Scheme

    Development
    Hostinger

    Highlights

    Need more storage or Thunderbolt 5 ports? OWC delivers new gear for video pros

    January 7, 2025

    Premium hardware maker OWC unveils a new RAID storage unit and Thunderbolt 5 hub. Source:…

    CVE-2025-44881 – Wavlink WL-WN579A3 Command Injection Vulnerability

    May 20, 2025

    AlphaFold 3 predicts the structure and interactions of all of life’s molecules

    May 27, 2025

    Automate interval partitioning maintenance and monitoring in Amazon RDS for PostgreSQL and Amazon Aurora PostgreSQL – Part 2

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

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