Your problem is that you are reassigning to the "netcost" variable over and over again instead of updating it. Given I don't know exactly what this is supposed to do, I'm going to assume that you need to change in the if statement:
1 2 3
netcost=gross*.50 /* Duration getting 50% off if the caller calls at the time between 6:00pm (1800) upto 8:00am (0800)*/
netcost=gross-discount; /* Duration minus discount */
netcost=gross+tax; /* Duration plus tax */
to
1 2 3
netcost=gross*.50 /* Duration getting 50% off if the caller calls at the time between 6:00pm (1800) upto 8:00am (0800)*/
netcost=netcost-discount; /* Duration minus discount */
netcost=netcost+tax; /* Duration plus tax */
and in the else if statement:
1 2
netcost=gross-discount; /* Duration minus discount */
netcost=gross+tax; /* Duration plus tax */
to
1 2
netcost=gross-discount; /* Duration minus discount */
netcost=netcost+tax; /* Duration plus tax */
" "Your code goes here"
time>=1800 && time<=800
1
2
3
4
if( duration>=60 or /*...*/ ){
//...
}
else if(duration>=60 or /*...*/)
make no sense
1
2
3
4
gross=duration*.40;
//...
netcost=gross+tax; /* Duration plus tax */
printf("Net Cost: %.2f",netcost);
That's what you are doing in both branches. As you are doing the same, the result will be the same. "
Sir what Im trying to do is, if (duration>=60 || time>=1800 && time<=800 || end>=1800 && end<=800)*(6:00pm (1800pm) upto 800am (8:00am) *the caller will have 50% discount
and else if (duration>=60 || time<=1799 && time>=801 || end<=1799 && end>=801) (military time *(8:00am (800am) upto 6pm(1800pm)* the caller won't have 50% discount.