I have an assignment to create a class Input and have method public static int readInt(Scanner in, String prompt, String error, int min, int max) I was provided the main method but have no idea what I'm supposed to be putting in the class Input. This is what I have:
import java.util.Scanner;
public class Input
{
public static int readInt(Scanner in, String prompt, String error, int min, int max)
{
Scanner age = in;
if (age > 1 && age < 150)
return age;
return age;
}
}
import java.util.Scanner;
public class AgePrinter
{
public static void main(String[] args)
{
Scanner in = new Scanner(System.in);
int age = Input.readInt(in, "Please enter your age", "Illegal Input--try again", 1, 150);
System.out.println("Next year, you'll be " + (age + 1));
}
}