Search code examples
javadateoperatorslogical-and

Bad Operand types for binary operator && when trying to calculate birthdate from current date


I am trying to get a user to input YR MON DAY and then system calculate the current age based on the provided input and show the age on the screen.

Here is the beginning to my code:

static void checkAgeFormat(int current_date, int current_month,
                            int current_year, int birth_date,
                            int birth_month, int birth_year) {
    int f = 0;
    if(current_date <= 01 && current_date => 31) {
        System.out.println("Invalid current_date");
        f = 1;
    }

I am getting a "Bad Operand types for binary operator &&" I cannot figure out why, and I am fairly new to coding. Thanks for any help


Solution

  • It is >= not => so if(current_date<=1 && current_date>=31)

    (don't use 0 as prefix for numbers, it causes them to be interpreted as octal)