Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. can't figure out this calculation

can't figure out this calculation

Scheduled Pinned Locked Moved C / C++ / MFC
helptutorialquestion
4 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • G Offline
    G Offline
    godzooky
    wrote on last edited by
    #1

    sorry about the formatting - i don't know how to make a table. take these numbers...

    Cost; Age; Cost * Age
    x; 6;
    8,025; 20; 160,500
    346,950; 47; 16,306,650
    279,252; 58; 16,196,616
    387,640; 69.2; 26,824,688
    84,500; 80; 6,760,000
    Totals
    1,106,367; 59.9; 66,248,454

    the task is to find x which brings the total Age (59.9) down to 40. now, the total cost number (1,106,367) can not change. meaning, x must be subtracted out starting from the bottom. so, if x is 80,000, 84,500 is reduced to 4,500 and Cost * Age becomes 360,000. the idea is bring total Cost * Age down to 44,254,680 (1,106,467 * 40). i just can not for the life of me figure out how to calculate x. can anyone help? thanks.

    B realJSOPR T 3 Replies Last reply
    0
    • G godzooky

      sorry about the formatting - i don't know how to make a table. take these numbers...

      Cost; Age; Cost * Age
      x; 6;
      8,025; 20; 160,500
      346,950; 47; 16,306,650
      279,252; 58; 16,196,616
      387,640; 69.2; 26,824,688
      84,500; 80; 6,760,000
      Totals
      1,106,367; 59.9; 66,248,454

      the task is to find x which brings the total Age (59.9) down to 40. now, the total cost number (1,106,367) can not change. meaning, x must be subtracted out starting from the bottom. so, if x is 80,000, 84,500 is reduced to 4,500 and Cost * Age becomes 360,000. the idea is bring total Cost * Age down to 44,254,680 (1,106,467 * 40). i just can not for the life of me figure out how to calculate x. can anyone help? thanks.

      B Offline
      B Offline
      Budric B
      wrote on last edited by
      #2

      How is the age total 59.9 when you have 6 + 20 + 27 + 58 + ... How can you choose x to be anything but 0 if you want to total cost to remain the same? I don't think your problem is well defined.

      1 Reply Last reply
      0
      • G godzooky

        sorry about the formatting - i don't know how to make a table. take these numbers...

        Cost; Age; Cost * Age
        x; 6;
        8,025; 20; 160,500
        346,950; 47; 16,306,650
        279,252; 58; 16,196,616
        387,640; 69.2; 26,824,688
        84,500; 80; 6,760,000
        Totals
        1,106,367; 59.9; 66,248,454

        the task is to find x which brings the total Age (59.9) down to 40. now, the total cost number (1,106,367) can not change. meaning, x must be subtracted out starting from the bottom. so, if x is 80,000, 84,500 is reduced to 4,500 and Cost * Age becomes 360,000. the idea is bring total Cost * Age down to 44,254,680 (1,106,467 * 40). i just can not for the life of me figure out how to calculate x. can anyone help? thanks.

        realJSOPR Offline
        realJSOPR Offline
        realJSOP
        wrote on last edited by
        #3

        Homework alert. Homework alert. If this had been an actual programming question, you would see real live answers from actual programmers. This has been a service of the Emergency Programming Association. ------- sig starts "I've heard some drivers saying, 'We're going too fast here...'. If you're not here to race, go the hell home - don't come here and grumble about going too fast. Why don't you tie a kerosene rag around your ankles so the ants won't climb up and eat your candy ass..." - Dale Earnhardt "...the staggering layers of obscenity in your statement make it a work of art on so many levels." - Jason Jystad, 10/26/2001

        1 Reply Last reply
        0
        • G godzooky

          sorry about the formatting - i don't know how to make a table. take these numbers...

          Cost; Age; Cost * Age
          x; 6;
          8,025; 20; 160,500
          346,950; 47; 16,306,650
          279,252; 58; 16,196,616
          387,640; 69.2; 26,824,688
          84,500; 80; 6,760,000
          Totals
          1,106,367; 59.9; 66,248,454

          the task is to find x which brings the total Age (59.9) down to 40. now, the total cost number (1,106,367) can not change. meaning, x must be subtracted out starting from the bottom. so, if x is 80,000, 84,500 is reduced to 4,500 and Cost * Age becomes 360,000. the idea is bring total Cost * Age down to 44,254,680 (1,106,467 * 40). i just can not for the life of me figure out how to calculate x. can anyone help? thanks.

          T Offline
          T Offline
          Toni78
          wrote on last edited by
          #4

          godzooky, the problem is a bit complicated. It is one of those problems that are studied in game theory and linear programming. I tried to solve it but my current mathematical skills leave much to be desired for. I have a minor in it but I can barely remember to solve a second degree equation and let alone a system of equations with a lot of restrictions. By increasing and decreasing the costs you decrease and increase the rate of the function Cost*Age. You have to find a point in where the rate you increase X and the rate where you decrease the other costs have to satisfy the condition that SUM OF ALL (Cost*Age) ~ 44,000,000. Let me give you something to start with and you might try to get a feasible solution from there. Lets call Cost Ci where i = 0 to 5 and where Ci = x, C2 = 8,025 and so on. Ai is the Age and Ci*Ai = Cost*Age. The initial equation is: C0*A0 + C1*A1 + …+C5*A5 = 66,248,454. C0 is X and it’s initially 0 so this becomes: A0 + C1*A1 + …+C5*A5 = 66,248,454 Ai doesn’t change, only Ci does and lets call Di the amount that we will increment and decrement Ci. (C0+D1+D2+..D5)*A0 + (C1-D1)*A1+…+(C5-D5)*A5= 44,254,680. Don’t forget that since C0 = X which is 0 initially then D1+D2+…+D5 becomes your answer. Now you have to write some code which will assign values to Di until the equation is satisfied. At first I would recommend that you decrease those costs where the age is the highest because there the rate of the increase is higher and then slowly proceed with the other costs where the age is lower. Sorry, but this is the only help that I can provide at the moment. // Afterall, I realized that even my comment lines have bugs If the sun were to blow up, it would take us 7-8 minutes to realize it.

          1 Reply Last reply
          0
          Reply
          • Reply as topic
          Log in to reply
          • Oldest to Newest
          • Newest to Oldest
          • Most Votes


          • Login

          • Don't have an account? Register

          • Login or register to search.
          • First post
            Last post
          0
          • Categories
          • Recent
          • Tags
          • Popular
          • World
          • Users
          • Groups