Write a Javascript program for display number of days in a month based on the Input month and year.
🔶If the month is 1,3,5,7,8,10 or 12 the number of days in a month is 31.
🔶If the month is 4,6,9 or 11
the number of days in a month is 31.
🔶If the month is 2 ,and year is not the leap year, the number of days is 28.if the year is leap , the number of the days is 29.
<!DOCTYPE html>
<html>
<head>
<script language="javascript">
var y,m ;
y=prompt("Input year 0000");
m=prompt("Input month 00");
if(m==1)
{
alert ("31 days ");
}
else if(m==3)
{
alert ("31 days ");
}
else if(m==5)
{
alert ("31 days ");
}
else if( m==7)
{
alert ("31 days ");
}
else if(m==8)
{
alert ("31 days ");
}
else if(m==10)
{
alert ("31 days ");
}
else if(m==12)
{
alert ("31 days ");
}
else if( m==4)
{
alert ("30 days ");
}
else if(m==6)
{
alert ("30 days ");
}
else if(m==9)
{
alert ("30 days ");
}
else if(m==11)
{
alert ("30 days ");
}
else if(y%4==0 && m==2)
{
alert ("29 days ");
}
else if(y%4!=0 && m==2)
{
alert ("28 days ");
}
</script>
</head>
</html>
good
ReplyDelete