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
Roy Goodman - 30 Oct 2004 04:36 GMT
> public class Hw5
> { public static void main(String[] args)
I think it doesn't compile because you're calling methods you haven't
written yet. Finish the bottom of the file first ... then it should work.
Or don't call those methods until you've written them.
Roy
(remove "nospa" from Email to reply)
hilz - 30 Oct 2004 08:31 GMT
> // write getAverage method here that will receive 3 integers and return the
> average of them
[quoted text clipped - 4 lines]
> // write countVowels method here that will receive a string and return the
> number of vowels in the string
have you read this part of your homework?