I'm trying to make a method where the user inputs the hour (eg. 13:00 for 1pm) into the console (this is a console application) and depending on the hour of the day, my object would be a certain price. I've got Java to recognise the hours, but I'm having so much trouble with the early morning hours (00:00-04:59).
I've converted the time into an integer using substring and parseInt and the if statement below works well up until 23:59, if I type 01:00 or 03:30, nothing happens. Here's what I've done so far, I hope that you can help me. :)
int hrs = Integer.parseInt(hrsString);
int mHrs = 0;
if (hrs == 00)
mHrs = 24;
if (hrs == 01)
mHrs = 25
Etc. up to 04
if ((hrs >= 22) && (mHrs <= 28))
price = 100.00
else if ((hrs >= 05) && (hrs <= 16))
price = 20.00
Etc. up to 21.