POO utils package created
This commit is contained in:
parent
1c772f058b
commit
96aea37503
|
@ -0,0 +1,7 @@
|
||||||
|
package utils;
|
||||||
|
|
||||||
|
public class MathTools {
|
||||||
|
public static double round(double n, int places) {
|
||||||
|
return (Math.round(n * Math.pow(10, places))) / Math.pow(10, places);
|
||||||
|
}
|
||||||
|
}
|
|
@ -0,0 +1,21 @@
|
||||||
|
package utils;
|
||||||
|
|
||||||
|
import java.util.Scanner;
|
||||||
|
|
||||||
|
public class UserInput {
|
||||||
|
public static double getNumberBetween(Scanner sin, double min, double max) {
|
||||||
|
double input;
|
||||||
|
do {
|
||||||
|
input = sin.nextDouble();
|
||||||
|
} while (input > max || input < min);
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static double getPositiveNumber(Scanner sin) {
|
||||||
|
double input;
|
||||||
|
do {
|
||||||
|
input = sin.nextDouble();
|
||||||
|
} while (input <= 0);
|
||||||
|
return input;
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue