HOME

Thursday, November 10, 2016

WML programs to check whether year is leap year or not. if not then sum of year is printed.

#WML File
<?xml version="1.0" ?>
<wml>
<card id="card1" title="armstrong number">
<do type="accept" label="Check Year">
<go href="leap.wmls#check()"/>
</do>
</card>
</wml>

#WMLS script
extern function check()
{
var num=Dialogs.prompt("Enter year",0);
var year=Lang.parseInt(num);
var year1=year;
var rem;
var sum=0;
if(year%4==0 || year%400==0)
{
Dialogs.alert("It is leap year");
}
else
{
Dialogs.alert("it is not leap year");
while(year1>0)
{
rem=year1%10;
sum+=rem;
year1=year1 div 10;
}
Dialogs.alert("The sum of year is "+sum);
}
}

No comments:

Post a Comment