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);
}
}

WML program to check whether given number is armstrong or not.

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

#WMLS file
extern function check()
{
var number=Dialogs.prompt("Enter Number",0);
var n=Lang.parseInt(number);
var num=n;
var sum=0;
var rem;
if(n==0)
{
Dialogs.alert("It is not a armstrong Number");
}
else if(n>=1 && n<=9)
{
Dialogs.alert("It is armstrong Number");
}
else
{
while(n>0)
{
rem=n%10;
sum+=rem*rem*rem;
n=n div 10;
}
if(sum==num)
{
Dialogs.alert("It is armstrong Number");
}
else
{
Dialogs.alert("It is not armstrong Number");
}
}
}

Wednesday, November 9, 2016

WML program to check whether the given number is palindrome or not.

#WML FILE
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<card id="card1">
<p>
<do type="accept" label="Check Number">
<go href="prime.wmls#check()"/>
</do>
</p>
</card>
</wml>

#WMLS SCRIPT FILE
    extern function check()
    {
    var num=Dialogs.prompt("Enter Number",0);
    var n=Lang.parseInt(num);
    var rev=0;
    var number=n;
    while(n>0)
    {
    var rem=n%10;
    rev=rem+rev*10;
    n=n div 10;
    }
    if(rev==number)
    {
    Dialogs.alert("It is palindrome Number");
    }
    else
    {
    Dialogs.alert("It is not palindrome Number");
    }
    }
   

WML program to find the reverse of given number.

#WML FILE
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<card id="card1">
<p>
<do type="accept" label="Check Number">
<go href="prime.wmls#check()"/>
</do>
</p>
</card>
</wml>

#WMLS SCRIPT FILE 
  extern function check()
    {
    var num=Dialogs.prompt("Enter Number",0);
    var n=Lang.parseInt(num);
    var rev=0;
    var number=n;
    while(n>0)
    {
    var rem=n%10;
    rev=rem+rev*10;
    n=n div 10;
    }
    Dialogs.alert("The reverse of "+number+" is "+rev);
    }
   

Monday, November 7, 2016

WML program to find whether number is prime or not.

#WML FILE
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<card id="card1">
<p>
<do type="accept" label="Check Number">
<go href="prime.wmls#check()"/>
</do>
</p>
</card>
</wml>


#WMLS SCRIPT FILE
    extern function check()
    {

    var num=Dialogs.prompt("Enter Number",0);
    var n=Lang.parseInt(num);
        if(n==1)
        {
        Dialogs.alert("It is prime number");
        }
        else{
        var c=0;
    for(var i=1;i<=n;i++)
    {
    if(n%i==0)
    {
    c=c+1;
    } 
    }
    if(c==2)
    {
    Dialogs.alert("It is prime Number");
    }
    else
    {
    Dialogs.alert("It is not a prime number");
    }
    }
    }

WML program to Find Odd or Even number using script

#WML File
<?xml version="1.0"?>
<!DOCTYPE wml PUBLIC "-//WAPFORUM//DTD WML 1.2//EN"
"http://www.wapforum.org/DTD/wml12.dtd">
<wml>
<card id="card1">
<p>
<do type="accept" label="Check Number">
<go href="prime.wmls#check()"/>
</do>
</p>
</card>
</wml>

WMLS script File
extern function check()
{
var num=Dialogs.prompt("Enter Number",0);
var n=Lang.parseInt(num);
if(n%2==0)
{
Dialogs.alert("IT is even Number");
}
else
{
Dialogs.alert("It is odd Number");
}
}