I have to write a program that is going to read n phone call times (in seconds). And then, the program will calculate the total amount collected from all users.
The first 2 minutes is amount 100.
Every additional 10 seconds amount is 5.
I need the formula to find the total amount every additional 10 seconds (more than 2 minutes)..I wrote this code but it's not ok..Can you help me fix it?
int call_price( int secs )
{
constint min_cost = 100 ;
// for call duration up to 120 secs, cost is min_cost
if( secs <= 120 ) return min_cost ;
// for call duration > 120 secs, cost is min_cost
// plus 5 for every additional 10 seconds or part thereof
int extra_secs = secs - 120 ; // first 120 seconds are already accounted for
extra_secs += 9 ; // add 9 to round up to next higher multiple of 10
// 30 => 39/10 == 3
// 34 => 43/10 == 4
// 39 => 48/10 == 4
return min_cost + (extra_secs/10) * 5 ;
}