0

i have a problem calculating the cost with this code. the code is supposed to use the different call rates to calculte but it only uses the first rate. it is supposed to get the total cost of around 4 calls with different rates..sorry if it is too long but it is the smallest segment cuz it has the diiferent conditions for the 3 call rates.

```
for (i=0;i<S;i++)
{
if ((time_and_date[i].start.hours<7) && (time_and_date[i].end.hours<=7))
{
rate_one =((minutes[i])+(hours[i]*60))*0.10;
}
if ((time_and_date[i].start.hours<=7)&&(time_and_date[i].end.hours>7)&&(time_and_date[i].end.hours<=16))
{
temp_value=time_and_date[i].start.hours;
temp_value2=time_and_date[i].end.hours;
for(i=8;i<temp_value2;i++)
{
count_rate++;
}
for(i=temp_value;i<7;i++)
{
hour_rate++;
}
temp_rate=((count_rate*60)+(time_and_date[i].end.minutes))*0.15;
rate=(((time_and_date[i].start.minutes))+(hour_rate*60))*0.10;
rate_one=(rate+temp_rate);
}
if ((time_and_date[i].start.hours>7)&&(time_and_date[i].start.hours<=16) && (time_and_date[i].end.hours<=16))
{
rate_two =((minutes[i])+(hours[i]*60))*0.15;
}
if((time_and_date[i].start.hours<=16)&&(time_and_date[i].end.hours>16)&&(time_and_date[i].end.hours<23))
{
temp_value=time_and_date[i].start.hours;
temp_value2=time_and_date[i].end.hours;
for(i=16;i<temp_value2;i++)
{
count_rate++;
}
for(i=temp_value;i<16;i++)
{
hour_rate++;
}
temp_rate=((count_rate*60)+(time_and_date[i].end.minutes))*0.12;
rate=(((time_and_date[i].start.minutes))+(hour_rate*60))*0.15;
rate_two=(rate+temp_rate);
}
if ((time_and_date[i].start.hours>16)&&(time_and_date[i].start.hours<=23) &&(time_and_date[i].end.hours<=23))
{
rate_three =((minutes[i])+(hours[i]*60))*0.12;
}
if((time_and_date[i].start.hours<=23)&&(time_and_date[i].end.hours>23)&&(time_and_date[i].end.hours<7))
{
temp_value=time_and_date[i].start.hours;
temp_value2=time_and_date[i].end.hours;
for(i=23;i<temp_value2;i++)
{
count_rate++;
}
for(i=temp_value;i<23;i++)
{
hour_rate++;
}
temp_rate=((count_rate*60)+(time_and_date[i].end.minutes))*0.10;
rate=(((time_and_date[i].start.minutes))+(hour_rate*60))*0.15;
rate_three=(rate+temp_rate);
}
}
rate=rate_one+rate_two+rate_three;
return rate;
}
```