J
JavaMan
public class Hw5
{ public static void main(String[] args)
{ int x=10, y=12, z=8;
System.out.println("The largest of " + x + ", " + y + " and " + z + " is: "
+ getLargest(x,y,z));
System.out.println("The average of " + x + ", " + y + " and " + z + " is: "
+ getAverage(x,y,z));
char c1='a', c2='b', c3='u';
System.out.println(c1 + " is a vowel: " + isVowel(c1));
System.out.println(c2 + " is a vowel: " + isVowel(c2));
System.out.println(c3 + " is a vowel: " + isVowel(c3));
String s1="hello", s2="madam";
System.out.println(s1 + " is a palindrome: " + isPalindrome(s1));
System.out.println(s2 + " is a palindrome: " + isPalindrome(s2));
System.out.println(s1 + ": has " + countVowels(s1) + "vowels");
System.out.println(s2 + ": has " + countVowels(s2) + "vowels");
}
// write the getLargest method here that will receive 3 integers and return
the largest of them
// it starts like the following
public static int getLargest(int a, int b, int c)
{
if (a >= b && a >= c)
return a;
else if (b >= a && b >= c)
return b;
return c;
}
}
// write getAverage method here that will receive 3 integers and return the
average of them
// write isVowel method here that will receive a character and return "true"
if it is vowel, return "false" otherwise
// write isPalindrome method here that will receive a string and return
"true" if it is a palindrome, return "false" otherwise
// write countVowels method here that will receive a string and return the
number of vowels in the string
{ public static void main(String[] args)
{ int x=10, y=12, z=8;
System.out.println("The largest of " + x + ", " + y + " and " + z + " is: "
+ getLargest(x,y,z));
System.out.println("The average of " + x + ", " + y + " and " + z + " is: "
+ getAverage(x,y,z));
char c1='a', c2='b', c3='u';
System.out.println(c1 + " is a vowel: " + isVowel(c1));
System.out.println(c2 + " is a vowel: " + isVowel(c2));
System.out.println(c3 + " is a vowel: " + isVowel(c3));
String s1="hello", s2="madam";
System.out.println(s1 + " is a palindrome: " + isPalindrome(s1));
System.out.println(s2 + " is a palindrome: " + isPalindrome(s2));
System.out.println(s1 + ": has " + countVowels(s1) + "vowels");
System.out.println(s2 + ": has " + countVowels(s2) + "vowels");
}
// write the getLargest method here that will receive 3 integers and return
the largest of them
// it starts like the following
public static int getLargest(int a, int b, int c)
{
if (a >= b && a >= c)
return a;
else if (b >= a && b >= c)
return b;
return c;
}
}
// write getAverage method here that will receive 3 integers and return the
average of them
// write isVowel method here that will receive a character and return "true"
if it is vowel, return "false" otherwise
// write isPalindrome method here that will receive a string and return
"true" if it is a palindrome, return "false" otherwise
// write countVowels method here that will receive a string and return the
number of vowels in the string