NewcastleFan Posted January 17, 2011 Share Posted January 17, 2011 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 https://forums.phpfreaks.com/topic/224723-calculator-not-a-clue/ Share on other sites More sharing options...
btherl Posted January 17, 2011 Share Posted January 17, 2011 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 https://forums.phpfreaks.com/topic/224723-calculator-not-a-clue/#findComment-1161049 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.