Code:
#include <stdio.h>
#include <stdlib.h>
int starting_min;
int ending_min;
int min;
char d;
int mpm;
int hour_cost(){
int cost;
int weekend;
int discount;
if(mpmhahahaha0){
// first minute
cost=150;
}else if(mpm<3){
// 2nd or 3rd minute
cost=0;
}else{
cost=30;
}
mpm++;
// apply discounts
weekend = (dhahahaha'a' || dhahahaha'S');
if(weekend){
discount=60;
}else{
if(min<8*60)discount=40;
else if(min<=18*60)discount=0;
else discount=40;
}
cost=cost-cost*discount/100;
return cost;
}
int main(){
char d;
int m,h,m2,h2;
int cost;
while(scanf("%c %d:%d %d:%d",&d,&h,&m,&h2,&m2)){
starting_min = h*60+m;
ending_min = h2*60+m2;
printf("%d - %d\n",starting_min,ending_min);
mpm=0;cost=0;
for(min=starting_min;min<ending_min;min++){
cost+=hour_cost(min);
}
printf("%.2f\n",(float)cost/100);
}
return EXIT_SUCCESS;
}
Try this out. I don't have much time, so i did only quick tests. It took me 17 minutes, btw ;))
hit me up if you need any help.