Computer Science Canada Three Letter Acronyms |
Author: | ryanisilly [ Fri Feb 13, 2015 10:59 am ] |
Post subject: | Three Letter Acronyms |
Hi guys, I'm in an intro comp sci class and been trying to do this problem for hours. If anyone could give me some help on it, it would be really appreciated.[/img] |
Author: | Insectoid [ Fri Feb 13, 2015 11:06 am ] |
Post subject: | RE:Three Letter Acronyms |
What have you tried so far? |
Author: | ryanisilly [ Fri Feb 13, 2015 11:31 am ] |
Post subject: | RE:Three Letter Acronyms |
My main problem is just that I have no idea how to write my own method that does #2. I've missed some classes and all of question #2 is foreign language to me. |
Author: | Insectoid [ Fri Feb 13, 2015 12:04 pm ] |
Post subject: | RE:Three Letter Acronyms |
Do you know how to write a method? Do you know what a boolean is? What about a char? |
Author: | ryanisilly [ Fri Feb 13, 2015 12:20 pm ] |
Post subject: | RE:Three Letter Acronyms |
I think so, would it look something like this? private static void isUpperLetter( |
Author: | Insectoid [ Fri Feb 13, 2015 12:22 pm ] |
Post subject: | RE:Three Letter Acronyms |
Well that's the first part of it. You want it to return a boolean though, not void. |
Author: | ryanisilly [ Fri Feb 13, 2015 12:35 pm ] |
Post subject: | RE:Three Letter Acronyms |
Sooo something like this then? private static return isUpperLetter( From there I have no idea. |
Author: | DemonWasp [ Fri Feb 13, 2015 3:24 pm ] | ||
Post subject: | RE:Three Letter Acronyms | ||
For now, you want to declare functions using this template: private static returnType functionName ( arguments ) For a function like isUpperCase or isTLA, the return type would be boolean -- either true or false, but no other values. Since your function has a return type (other than void), you must make sure that the function eventually hits a return statement, and that the value you return is of the same type as the declared return type of the function. Start with this:
Once you get your program compiling, you can replace the "return true;" line with something that actually checks the requirements from your assignment (has exactly three letters, and all three are upper case, etc). |