# Applying multiple conditions to an 'if' statement

1 Ansicht (letzte 30 Tage)
Broughieee am 23 Okt. 2015
Beantwortet: Ken Atwell am 23 Okt. 2015
Okay, so I'm trying to do a homework assignment for my Matlab class. Here's the prompt:
"Design and implement a Matlab script that reads an integer value representing a year from the user. The purpose of the program is to determine if the year is a leap year (and therefore has 29 days in February) in the Gregorian calendar. A year is a leap year if it is divisible by 4, unless it is also divisible by 100 but not 400.
For example, the year 2003 is not a leap year, but 2004 is. The year 1900 is not a leap year because it is divisible by 100, but the year 2000 is a leap year because though it is divisible by 100, it is also divisible by 400.
Produce an error message for any input value less than 1582 (the year the Gregorian calendar was adopted)."
So far this is what I've accomplished: See link
However, I can't seem to figure out how to apply the condition that if the year is divisible by 100 and by 400, then it is a leap year, rather than it not being a leap year..
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Antworten (2)

Broughieee am 23 Okt. 2015
Bearbeitet: Broughieee am 23 Okt. 2015
uhmm.. I actually have more than what the link is showing..
##### 1 Kommentar-1 ältere Kommentare anzeigen-1 ältere Kommentare ausblenden
John D'Errico am 23 Okt. 2015

Melden Sie sich an, um zu kommentieren.

Ken Atwell am 23 Okt. 2015
You might be looking for logical operators.
##### 0 Kommentare-2 ältere Kommentare anzeigen-2 ältere Kommentare ausblenden

Melden Sie sich an, um zu kommentieren.

### Kategorien

Mehr zu Calendar finden Sie in Help Center und File Exchange

### Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by