CONVERT THE FOLLOWING WHILE LOOP PROGRAM SEGMENT TO FOR LOOP
1. a=10; b=10; 2. a=15;
while(a<=20) while(a>=1)
{ [Link](a*b); { a--;
a++; }
} [Link](a*a);
Write the method prototype :
Method compute accepts an integer and returns
a character
Method to check whether the given number is
even or odd
How are the following methods are invoked ?
void print()
boolean check (int n)
int calculate (String s, int n)
The following code CREATES AN OTP WITH 6 DIGITS
void OTP()
{
[Link](__________________________);
//malayalam, mom, QUEEN (Write output and explain)
class palin
{
boolean palindrome(String s)
{
int i, l=[Link](),j;
for(i=0,j=l-1;i<l/2;i++,j--)
{
if([Link](i)!=[Link](j))
return false;
}
return true;
}
}
//to count vowels and consonants (Write output and explain)
class vowel
{ void count(String s)
{ int i, l=[Link](),v=0,c=0;char ch;
for(i=0;i<l;i++)
{ ch=[Link](i);
if([Link](ch))
{ if("AEIOUaeiou".indexOf(ch)>=0)
v++;
else
c++; } }
[Link]("Number of vowels = "+v);
[Link]("Number of Consonants="+c);
}
}
//to calculate the LCm and GCD(54,60)
class lcmgcd
{
void calc(int m, int n)
{
int k;
for(k = [Link](m, n); k % m != 0 || k % n != 0; k++);
[Link]("LCM = " + k);
for(k = [Link](m, n); m % k != 0 || n % k != 0; k--);
[Link]("GCD = " + k);
}
}
Do selection sort of 10 numbers.