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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T15:49:35+00:00 2026-05-26T15:49:35+00:00

I have 2 convertor methods as below: private const decimal MaxValidValue = 99.99m; public

  • 0

I have 2 convertor methods as below:

private const decimal MaxValidValue = 99.99m;
public decimal ConvertABToC(decimal a, decimal b)
{
    return a * b;
}

public void ConvertCtoAB(decimal c, ref decimal a, ref decimal b)
{
    if (c > MaxValidValue*MaxValidValue)
    {
        throw new ApplicationException();
    }

    if (c <= MaxValidValue)
    {
        a = 1.00m;
        b = c;
    }
    else 
    {
        // need to introduce some logic or assumptions here
    }
}

There are 3 important things to know:

1) The a and b variables are in the range of 0.00 to 99.99 therefore c can’t have a value greater than 99.99*99.99

2) the a, b and c must not have more than 2 decimal precession e.g. a = 99.123 would be invalid.

3) you can use rounding if you’d need to as long as decimal.Round(a * b, 2) == c.

4) combinations like (1, 3), (3, 1), (2, 2), (1, 4), (0.5, 8) or even (0.25, 16) are all valid; it doesn’t matter as long as c would be the product of a and b.

How would you complete the implementation of ConvertCtoAB?

Many 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-05-26T15:49:35+00:00Added an answer on May 26, 2026 at 3:49 pm

    Multiply C by 10,000. Then factor this number into its prime factors. Then find a partition of the prime factors into two sets such that the product of the numbers in each set is less than 10,000. If such a partition can be found, then return these two products divided by 100 as A and B. Otherwise, add one to the number and try again.

    For example, if C=100.07, then the factors are 2, 2, 5, 5, 10007. Because one of the products must include the factor 10007, which is a prime number, the first condition can never be satisfied. So we try again with 1000701 = 3*3*3*13*2851. This time, we can partition the number, and we have A=3.51 and B=28.51 as a possible solution.

    You can do this at most 99 times. If you need 100 or more, than the input value cannot have been generated from ConvertABToC.

    This only guarantees that the result of ConvertCtoAB, when fed back into ConvertABtoC will produce the same C, not the other way around. It appears to violate rule #3, but then elsewhere the question is about rounding.

    If no rounding at all is allowed, then one should stop and report infeasibility after trying the original 10000*C.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two methods, one that I use to convert an image to a
I have converted my Datatable to json string use the following method... public string
I have a custom class declared as follows (in vb.net) <Serializable()> Public Class NumInfo
**Updated: (See below)**I have been looking around for couple of days and can't find
I'm having a brain cramp: I have a public interface SomeInterface and a static
i have a project that uses myBatis for persistence. method A below was working
I have a winform app for in house use where the below is very
I have method that is returning IQuerable given below: internal IQueryable<TradeLeads> GetLeadsByCategory(int categoryId) {
I have often encountered an error such as cannot convert from 'method group' to
I currently have an extension Method which converts an IEnumerable of type Tab into

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.