Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / First Aid / October 2004

Tip: Looking for answers? Try searching our database.

Student.HELP.Why does this code not compile?

Thread view: 
JavaMan - 30 Oct 2004 04:15 GMT
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?


Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.