Hey guys, I'm coding a homework assignment
I'm trying to make the session lok like this:
A session might look like this:
Year >>2100 ***
Value must be between 2001 and 2025
Year >>2010
This is what I have so far for the main class
Hehe, it doesn't work though.Code:import java.util.Scanner;
public class Packages
{
public static void main(String[] args)
{
Scanner keyboard = new Scanner(System.in);
System.out.print("Year>> ");
int year = keyboard.nextInt();
}
private static int getYear(Scanner keyboard, int year)
{ int newYear;
newYear = year;
if (newYear < 2001 && newYear > 2005)
System.out.println("Year should be between 2001 and 2005");
return year;
}
I've tried to create a private class inside that method which was suggested by my teacher.
I tried to use that instead ofCode:private static int GetInt(input, "Year", 2001, 2005)
I would so greatly appreciate any help from you guys.Code:private static int getYear(Scanner keyboard, int year)
Thanks you!

