Answer the question
In order to leave comments, you need to log in
How to generate real numbers?
Hello.
I can’t figure out how to generate real numbers so that they fit the conditions:
1) Number of the form: 00.00
2) Before the comma (integer) from 1 to 24
3) After the comma (hundredths) from 01 to 59
This is a kind of time for the schedule calls))
Answer the question
In order to leave comments, you need to log in
double getMyTime(int hours, int minutes) {
if (hours <= 0 || hours > 24) {
throw InvalidArgumentException("hours");
}
if (minutes < 0 || minutes > 59) {
throw InvalidArgumentException("minutes");
}
return hours + minutes / 100.;
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question