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 928429
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:00:27+00:00 2026-05-15T20:00:27+00:00

Note: This is a general programming question, not specific to any language, but feel

  • 0

Note: This is a general programming question, not specific to any language, but feel free to use the language of your choice in your answer to explain the logic.

I would like a method to take a string of text, say "Default(0-100)=20" and then extract out of that the default hourly wage would be 20 for hours 0 through 100. This could be then used for say “Default(101-245)=25” that the default hourly wage for hours 101 through 245 would be 25. Also allow it to define “Brian(0-29)=15” that the user “Brian” would have an non-default hourly wage of 15 for hours 0 through 29.

My first impression is to run the string through a regular expression says something like ^(\w*)\((\d*)-(\d*)\)$ where it could pickup the Text and the smaller and higher end of the range.

What would be the best way to store this information so it could be used later on? multidimensional array? hashes?

Once you do have the information stored, what would be the best way of actually using the information to good use?

How would you calculate the total wages earned if say we used "Default(0-100)=20" & "Default(101-245)=25" and the number of hours worked was 150.

  • 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-05-15T20:00:28+00:00Added an answer on May 15, 2026 at 8:00 pm

    I think type of storage and regular expressions would be the least of your concerns in modeling this. You are essentially writing a simple rule engine to compute the salary of an employee. Figuring out what those rules is the most important part of this problem. Ensuring that rules are complete, consistent, and deterministic is another important piece. By deterministic, I mean you cannot have two rules like:

    Default(0-100)=20
    Default(50-100)=25
    

    as the system does not know how to compute the wages for hours 50-100 since there are two choices. By complete, I mean the rules should be able to compute the wages given any employee and the number of hours they worked. Take another example:

    Default(0-100)=20
    Default(125-150)=25
    

    If an employee worked for 150 hours, the system does not know their earned wages for hours 101-125. So incompleteness is another problem.

    Assuming the rules are complete and deterministic, we can proceed with modeling. If hours worked can be fractional, then the solution will need to proportionally split the hourly wage. It looks like there is a default salary and then salaries specific to an employee. Salaries specific to an employee always take precedence over the default salary. So in a simple if-else pseudo-code, it would look like:

    get-wages (employee, hours-worked)
        total-wage = 0
    
        for each ith hour worked
            hourly-wage = get-hourly-wage (employee, ith-hour)
            fraction-of-hour-worked = get-fraction-of-hour-worked(ith-hour, hours-worked)
            total-wage += hourly-wage * fraction-of-hour-worked
    
        return total-wage
    end
    
    get-hourly-wage (employee, hour-number)
        if employee has specific wage for hour number
            return that
        else if there is default wage for hour number
            return that
        else
            throw error("no wage available for hour number [hour-number]")
    end
    
    get-fraction-of-hour-worked (hour-number, hours-worked)
        difference = hours-worked - hour-number
        if difference >= 1
            return 1
        else
            return difference
    end
    

    Checkout this article that gives one approach to writing a rule engine and interestingly it uses employees and wages as an example, so it might be helpful.

    Some more interesting articles about rule engines that you might find useful:

    • Using a Rule Engine
    • Decision Tables
    • Production System
    • Production Rules
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Ask A Question

Stats

  • Questions 510k
  • Answers 510k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer Regarding your second EDIT - your loop is wrong. (1)… May 16, 2026 at 5:01 pm
  • Editorial Team
    Editorial Team added an answer You can use DeckPanel and switch the view using showWidget(index)… May 16, 2026 at 5:01 pm
  • Editorial Team
    Editorial Team added an answer Your main problem is that you go through all txtB… May 16, 2026 at 5:01 pm

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

Related Questions

This is a language design question: Do you think unreachable code (in programming languages
I know this in general is beyond the scope of SO, but I am
Note: I'm more interested in understanding general Go concepts/patterns, rather than solving this contrived
Though the question is very specific, I'd also really appreciate general advice and other
I'm relatively(read: stupid newbie) familiar with disassembly but this bit stumped me: I have
I'm from a Windows programming background when writing tools, but have been programming using
I am currently learning F# and functional programming in general (from a C# background)
I'm new to OpenGL and graphics programming in general, though I've always been interested
In general, what kinds of design decisions help an application scale well? (Note: Having
So, I've come back to ask, once more, a patterns-related question. This may be

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.