Click here to Skip to main content
16,016,204 members
Home / Discussions / Algorithms
   

Algorithms

 
GeneralRe: Critiques of measurements for the cryptography Pin
El Corazon24-Oct-07 10:21
El Corazon24-Oct-07 10:21 
GeneralRe: Critiques of measurements for the cryptography Pin
CPallini24-Oct-07 21:26
mveCPallini24-Oct-07 21:26 
Questionbarcode algorithm Pin
memaia23-Oct-07 22:19
memaia23-Oct-07 22:19 
AnswerGoogle Pin
CPallini23-Oct-07 22:32
mveCPallini23-Oct-07 22:32 
QuestionLogic for Billing Pin
briogene21-Oct-07 21:07
briogene21-Oct-07 21:07 
AnswerRe: Logic for Billing Pin
Dan Neely22-Oct-07 2:15
Dan Neely22-Oct-07 2:15 
GeneralRe: Logic for Billing Pin
DQNOK22-Oct-07 9:20
professionalDQNOK22-Oct-07 9:20 
AnswerRe: Logic for Billing [modified] Pin
DQNOK22-Oct-07 9:00
professionalDQNOK22-Oct-07 9:00 
Your algorithm looks suspicious to me. Please verify (just for peace of mind) that the more you use, the more expensive each successive unit is.

I don't work with utilities, and perhaps this is completely correct. It is just counter to my free-market thinking, where, the more you buy, the cheaper each succeding unit is...

static int tarrifAmounts[] = {0, 10, 20, 40, 100, INT_MAX};
static int tarrifRates[] =   {0, 12, 33, 44, 56,  64};

int bill( int amount )
{
   int ret = 0;
   int tindx = 1;
   while( amount > tarrifAmounts[tindx] )
   {
      ret += tarrifRates[tindx] * (tarrifAmounts[tindx]-tarrifAmounts[tindx-1]);
      tindx++ ;
   }
   ret += tarrifRates[tindx] * (amount - tarrifAmounts[tindx-1]);
   return ret;
}

Convert it to VB, check whether it works, and send my payment to ...

Wink | ;)

David

-- modified at 16:54 Monday 22nd October, 2007
OOPS: I just noticed that you said there is a minumum charge. Therefore, the actual billing amount will need to be:
max(MINIMUM_CHARGE, bill(amountUsed))
Or just embed it into the bill algorithm. Whatever works for you.
GeneralRe: Logic for Billing Pin
briogene26-Oct-07 22:08
briogene26-Oct-07 22:08 
GeneralRe: Thanks Pin
DQNOK29-Oct-07 10:25
professionalDQNOK29-Oct-07 10:25 
AnswerRe: Logic for Billing Pin
Duane in Japan23-Oct-07 6:08
Duane in Japan23-Oct-07 6:08 
QuestionPlease HELP! Carl Gauss Algorithm for getting Easter on specified year JAVA Pin
Mr. Deja Vu16-Oct-07 15:01
Mr. Deja Vu16-Oct-07 15:01 
AnswerRe: Please HELP! Carl Gauss Algorithm for getting Easter on specified year JAVA Pin
cp987616-Oct-07 15:55
cp987616-Oct-07 15:55 
GeneralRe: Please HELP! Carl Gauss Algorithm for getting Easter on specified year JAVA Pin
Mr. Deja Vu16-Oct-07 18:15
Mr. Deja Vu16-Oct-07 18:15 
QuestionPlotting large amount of data points Pin
nico8015-Oct-07 11:26
nico8015-Oct-07 11:26 
AnswerRe: Plotting large amount of data points Pin
cp987615-Oct-07 12:38
cp987615-Oct-07 12:38 
GeneralRe: Plotting large amount of data points Pin
nico8015-Oct-07 14:32
nico8015-Oct-07 14:32 
GeneralRe: Plotting large amount of data points Pin
nico8016-Oct-07 11:25
nico8016-Oct-07 11:25 
GeneralRe: Plotting large amount of data points Pin
cp987616-Oct-07 14:52
cp987616-Oct-07 14:52 
GeneralRe: Plotting large amount of data points Pin
Ri Qen-Sin23-Oct-07 14:59
Ri Qen-Sin23-Oct-07 14:59 
GeneralA Prayer for Archimedes Pin
Bassam Abdul-Baki10-Oct-07 6:44
professionalBassam Abdul-Baki10-Oct-07 6:44 
GeneralRe: A Prayer for Archimedes Pin
IdUnknown10-Oct-07 7:16
IdUnknown10-Oct-07 7:16 
GeneralRe: A Prayer for Archimedes Pin
Bassam Abdul-Baki10-Oct-07 7:26
professionalBassam Abdul-Baki10-Oct-07 7:26 
Questionfill memory with a pattern Pin
DQNOK10-Oct-07 5:21
professionalDQNOK10-Oct-07 5:21 
AnswerRe: fill memory with a pattern Pin
DQNOK11-Oct-07 7:35
professionalDQNOK11-Oct-07 7:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.