Hi Friends;
I am a newbie in
Java and took some classes to learn it. I try to write a small program requesting user input a date (integer) next or previous date (
String). Then it calculates the next or the previous date according to "next" or "previous" entered. I need to use a if .. else loop for this. I wrote something like this:
When I rum this program it skips the comparison block:
if ( ( date < firstDay ) && (date > lastDay) ) {
System.out.println("Enter a date between 1-30");
System.exit(-2);
}
So for example if I enter a number like 50 or 0 it won't generate an error message which I am expecting.
In addition after I enter a number it asks me to enter "next" or "previous" . It stops execution if I don't enter "next" or "previous" which is good. But in case if I enter next or previous it will always say there is no previous date or there is no next date but won't ever calculate finalDate.
I'm suspecting there is some kind of mistake in my logical comparisons but couldn't really figure out what it is. Any comment will be highly appreciated.
Thanks