POO utils package created

This commit is contained in:
TiagoRG 2023-02-18 14:09:52 +00:00
parent d8e1634afc
commit 2c6f92e980
2 changed files with 28 additions and 0 deletions

View File

@ -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);
}
}

View File

@ -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;
}
}