Student.HELP.Why does this code not compile?

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
 
L

Lee Weiner

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

Because you haven't written the methods you call in main() ( getAverage,
isVowel, isPalindrome, countVowels.)

Comment out the code in main that calls those methods until you include them
in your program.

Lee Weiner
lee AT leeweiner DOT org
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

Forum statistics

Threads
473,744
Messages
2,569,482
Members
44,901
Latest member
Noble71S45

Latest Threads

Top