Hey you guys I'm having trouble determining something. This programthat im tryin to do determines the price for an adult by militarytime and if the military time is 16:30 or earlier then they get thematinee price ($7.00), other wise its $10.00. The user gets toinput an hour and minute in military time. FOr example: Start hour (0-23): 15 (hour_time) Start minute (0-59): 45 (minute_time) So the time I have is 15:45. Now this time will determine theprice. How would you write an appropriate if and else statement forthis? Because I was thinking of doing this: if (hour_time < = 16 && minute_time <= 30){ printf("The price is $7.00); } else { printf("The price is $10.00); } but the flaw of this code is that if its like 15:45 (which isclearly under 16:30) then its going to evaluate false because 45 isgreater than 30. any help please?? thank you very much. Start minute (0-59): 45 (minute_time) So the time I have is 15:45. Now this time will determine theprice. How would you write an appropriate if and else statement forthis? Because I was thinking of doing this: if (hour_time < = 16 && minute_time <= 30){ printf("The price is $7.00); } else { printf("The price is $10.00); } but the flaw of this code is that if its like 15:45 (which isclearly under 16:30) then its going to evaluate false because 45 isgreater than 30. any help please?? thank you very much.
Explanation / Answer
#include #include int main(void){ int hr = 16, min = 31; if (hr < 16) { printf("The price is$7.00 "); } else if(hr >= 16 && min