Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8005183
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 4, 20262026-06-04T17:09:24+00:00 2026-06-04T17:09:24+00:00

I have this really long method: public decimal decDiscount(QuoteData quoteData) { if (TotalChapter7(quoteData) >=

  • 0

I have this really long method:

public decimal decDiscount(QuoteData quoteData)
    {
        if (TotalChapter7(quoteData) >= 7499)
            return 5300;
        else if (TotalChapter7(quoteData) >= 7449)
            return 5300;
        else if (TotalChapter7(quoteData) >= 7399)
            return 5250;
        else if (TotalChapter7(quoteData) >= 7349)
            return 5200;
        else if (TotalChapter7(quoteData) >= 7299)
            return 5200;
        else if (TotalChapter7(quoteData) >= 7249)
            return 5150;
        else if (TotalChapter7(quoteData) >= 7199)
            return 5100;
        else if (TotalChapter7(quoteData) >= 7149)
            return 5100;
        else if (TotalChapter7(quoteData) >= 7099)
            return 5050;
            //...
        else if (TotalChapter7(quoteData) >= 1199)
            return 1100;
        else if (TotalChapter7(quoteData) >= 1149)
            return 1100;
        else if (TotalChapter7(quoteData) >= 1099)
            return 1050;
        else if (TotalChapter7(quoteData) >= 1049)
            return 1000;
        else
            return 0;
    }

which has a recurring pattern which can be illustrated by the following Excel sheet:

Excel sheet part 1
……>>>>
Excel sheet part 2

Starting from the highest “Fee” (7499), the fee is dropping 50 on each statement. However, the return (or “Discounted Price”) stays the same for each 100 (two 50 drops in Fee), then drops 50 itself for one return (one 50 drop in Fee), and then repeats.

As you can see my method is pretty long (what I left out between 7049 and 1249). Is there something I can do to shorten this?

Thanks.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-04T17:09:25+00:00Added an answer on June 4, 2026 at 5:09 pm

    You guys are really overcomplicating this. Any approach along the lines of trying to solve this using integer arithmetic is a bad idea. Look how hard it is for a bunch of really smart people (we are all really smart, aren’t we?) to even get it right in the first place. It’s really hard to discover, it’s really hard to understand, it’s hard to get right, and it’s a bitch to maintain.

    You need an approach that is easy to understand, and easy to maintain. Look at your original post, you have an English description of the rule.

    However, the return (or “Discounted Price”) stays the same for each 100 (two 50 drops in Fee), then drops 50 itself for one return (one 50 drop in Fee), and then repeats.

    The code practically writes itself:

    public int GetFeeFromQuoteData(QuoteData quoteData) {
        int fee = 5300;
        int difference = 7449 - TotalChapter7(quoteData);
        bool isTwoStep = true;
    
        while (difference > 0) {
            if (isTwoStep) {
                difference -= 50;
            }
            else {
                difference -= 100;
            }
            fee -= 50;
            isTwoStep = !isTwoStep;
        }
        return fee;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have this case <WrapPanel> <CheckBox>Really long name</CheckBox> <CheckBox>Short</CheckBox> <CheckBox>Longer again</CheckBox> <CheckBox>Foo</CheckBox> <Slider MinWidth=200
Really quick jQuery question... I have this function: $(document).ready(function() { $('a#show1').click(function() { $('.item1').toggle(1000); return
Lets say I have this extention method: public static bool HasFive<T>(this IEnumerable<T> subjects) {
Say I have a generic method with multiple type constraints, this this: public static
I have a simple WCF service method: [OperationContract] public SetupGameResult SetupGame(long player1Id, long player2Id,
Ok I have this problem that I've never had before, it's really bugging me.
this seems to be weird but it really happened. I have this code working
I have read that you can do it, but would this really improve performance
I have really no idea why I'm asking this as this a really completely
This is really getting to me now.I have a form that loads when the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.