/* Project 1 Solution (one possibility out of many) */
/* Terry Smith, TA */

#include<stdio.h>

#define SIXAM 6*60
#define NOON 12*60
#define SIXPM 18*60
#define MIDNIGHT 24*60

main()
{

   int start, stop, i, t1=0, t2=0, t3=0, t4=0;
   float total;

   printf(" This program will attempt to calculate your ISP bill \n\n");
   printf(" Please enter the connection start and stop times :" );
   scanf("%d%d",&start,&stop);

   while( (start != 0) || (stop != 0) )
   {
       /* convert to minutes */
       start = (60 *(start/100) + start%100);
       stop = (60 *(stop/100) + stop%100);

       for(i=start; i<stop; i++)
       {
           if( i < SIXAM )
           {
               t1++;
           }
           else if ( i< NOON )
           {
               t2++;
           }
           else if ( i< SIXPM )
           {
               t3++;
           }
           else if ( i< MIDNIGHT )
           {
               t4++;
           }
       }

   printf(" Please enter the connection start and stop times :" );
   scanf("%d%d",&start,&stop);
   }

   total = (t1*.02) + (t2*.03) +(t3*.05) + (t4*.06);

   printf(" %3d minutes at 0.02 cost $ %.2f\n", t1, t1*.02);
   printf(" %3d minutes at 0.03 cost $ %.2f\n", t2, t2*.03);
   printf(" %3d minutes at 0.05 cost $ %.2f\n", t3, t3*.05);
   printf(" %3d minutes at 0.06 cost $ %.2f\n", t4, t4*.06);
   printf(" ------------------------------------\n");
   printf(" Total Cost: $ %.2f \n\n ",total);
}