Hi,

I am writing an application class for a Lunar Calendar I created in a service class and I have to make sure it is able to detect that the year entered is not in the range of values(I have done this in the service class using a switch statement) and be able to detect if the year is a valid integer. I need a little help with the last one.

Here is what I have so far:

package classes;

import java.util.InputMismatchException;
import java.util.Scanner;

public class LunarCalendarApp {

public static void main(String[] args) {

Scanner in = new Scanner(System.in);

final int SENTINEL = -1;
boolean validInput = false;

System.out.println("Enter a year:");
int someYear = in.nextInt();

while(someYear != SENTINEL){

LunarCalendar calen = new LunarCalendar (someYear);
calen.Calendar();

do {

try {

System.out.println("Enter a year:");
validInput = in.hasNext();
someYear = in.nextInt();

}

catch (InputMismatchException e)
{ System.out.println("This is not an integer!");
in.next();
}

}while(!validInput);

}
}

}

Similar Questions
  1. Hi,For an assignment I am doing, we have to have 2 service classes and one application class. One service class is already
    1. answers icon 2 answers
  2. i need help on theseWhat does a hieroglyphic writing system use instead of alphabetic letters? A. cuneiform shapes B. drawings
    1. answers icon 32 answers
    1. answers icon 1 answer
    1. answers icon 1 answer
more similar questions