diff --git a/1ano/2semestre/poo/src/utils/MathTools.java b/1ano/2semestre/poo/src/utils/MathTools.java new file mode 100644 index 0000000..fa7c389 --- /dev/null +++ b/1ano/2semestre/poo/src/utils/MathTools.java @@ -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); + } +} diff --git a/1ano/2semestre/poo/src/utils/UserInput.java b/1ano/2semestre/poo/src/utils/UserInput.java new file mode 100644 index 0000000..6aa8238 --- /dev/null +++ b/1ano/2semestre/poo/src/utils/UserInput.java @@ -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; + } +}