Jump to content

Calculator - Not a clue!


NewcastleFan

Recommended Posts

Hey guys, hope you are all well.

 

I've got this project I'm working on and it requires a calculator to work out a cost via peoples inputs in a form... However I'm trying to figure out how to go about doing it... the basis is:

 

(A * B) + Base Rate = Cost Per Month

 

Value A can be input by the user, Value B is a cost, a cost that changes with the value of A.

 

E.g

 

If A = 10 then B = £1.00

 

Or

 

If A = 20 then B = £0.90

 

I'm thinking I'm not going to be able to do this without having a database to store all of these numbers. To top it off, it has to have 4 different options in the first choice, which then determains witch list of values too read from.

 

I'm completly confused at the moment, wondering if anyones got any suggestions of how to take this or have done anything like this in the past!

 

Thanks

 

Link to comment
Share on other sites

You could write a function which takes an A value and the "4 different choice" as input and returns a B value.  That function can have a series of if/then/else to decide what to return.

 

As for how to implement the calculation of B from A, the most appropriate implementation depends on the rules for calculating it.  If B is the same for a range of A values, you should use if/then/else.  If B changes continuously with a change in A (ie there's a different B for every A), then you should do it with a calculation instead.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.