Ex. 5.12, Ex. 5.14, and Ex. 5.15
//*****************************************************
// Ex. 5.12
//*****************************************************
public class ex5point12 {
public int maxOfTwo (int num1, int num2)
{
int result = num1;
if (num2 > num1)
result = num2;
return result;
}
}
//*****************************************************
// Ex. 5.14
//*****************************************************
public class ex5point14 {
public boolean evenlyDivisible (int num1, int num2)
{
boolean result = false;
if (num1 != 0 && num2 != 0)
if (num1 % num2 == 0 || num2 % num1 == 0)
result = true;
return result;
}
}
//*****************************************************
// Ex. 5.15
//*****************************************************
public class ex5point15 {
public boolean isAlpha (char ch)
{
return ( (ch >= 'a' && ch <= 'z') ||
(ch >= 'A' && ch <= 'Z') );
}
}
No comments:
Post a Comment