Results 1 to 6 of 6
Thread: Homework Help please!
- 03-18-2012, 06:06 PM #1
Member
- Join Date
- Feb 2012
- Posts
- 12
- Rep Power
- 0
Homework Help please!
So I have been able to achieve the problems before this one.
Here is the directions to which I have to do.
The class, DotDashLetters2, is also an extension of the Java code found in the DotDash class of Exercise 1. It contains header comments and method headers for one additional user-defined void method. This method takes a single parameter (char letter) and displays its corresponding dot-dash pattern followed by a space.
a. Add code to the method, doLetter(), to produce the associated dot-dash patterns as given in the table found in Exercise 2. Your logic must invoke only the methods dot(), dash() and space() to produce each required pattern.
b. Add logic as indicated by comments in the main method to produce patterns corresponding to the words, “to”, “ate” and “tattoo”. Each pattern must be displayed on a single line. Your logic must use only the methods doLetter() and end() to produce each pattern. The required output is the same as for Exercise 2.
Here is my code
I need my output to be look like this.Java Code:public class DotDashLetters2 { public static void dot() { System.out.print("."); } public static void dash() { System.out.print("-"); } public static void space() { System.out.print(' '); } public static void end() { System.out.println(); } public static void doLetter(char letter) { } public static void main(String[] args) { // 1. ADD logic to display the word, "to", on the console // 2. ADD logic to display the word, "ate", on the console // 3. ADD logic to display the word, "tattoo", on the console } }
I basically have to add something into the Void doLetter part, but I really dont know what. I missed my class that day. Can anyone help me out?Java Code:- --- .- - . - .- - - --- ---
Last edited by Fubarable; 03-18-2012 at 09:01 PM.
- 03-18-2012, 06:45 PM #2
Member
- Join Date
- Feb 2012
- Posts
- 35
- Rep Power
- 0
Re: Homework Help please!
Is it like decoding morse code?
- 03-18-2012, 07:01 PM #3
Member
- Join Date
- Feb 2012
- Posts
- 35
- Rep Power
- 0
Re: Homework Help please!
It is definitely morse code.
I'll start off.
For morse code goto: http://www.google.co.uk/imgres?q=mor...:0&tx=85&ty=23Java Code:public static void doLetter(char letter) { if letter.equals(t) { dash(); space(); } }
- 03-18-2012, 07:35 PM #4
Member
- Join Date
- Feb 2012
- Posts
- 12
- Rep Power
- 0
Re: Homework Help please!
I receive an error when I do this. Something about how cannot compare..and it needs to be a string.
It might be morse code, im not sure, but In the end, i have to type in the word "to" and it does the dashes and periods. Any more help? ):
-
Re: Homework Help please!
char are primitives, and you cannot call methods on primitives. Instead check if the letter == 't', not if letter.equals(t) (which makes no sense any way since t is then thought to be an undeclared variable.
- 03-19-2012, 02:44 AM #6
Member
- Join Date
- Feb 2012
- Posts
- 12
- Rep Power
- 0
Similar Threads
-
Homework help
By lackingunderstanding4now in forum New To JavaReplies: 4Last Post: 11-08-2010, 03:18 AM -
Help me pls It is my homework:(
By pinar in forum New To JavaReplies: 3Last Post: 10-19-2010, 10:11 PM -
Please Help with Homework
By theuser in forum Advanced JavaReplies: 2Last Post: 07-30-2009, 03:37 PM -
Homework help...
By robrobrob in forum New To JavaReplies: 4Last Post: 10-17-2008, 04:24 AM


LinkBack URL
About LinkBacks
Reply With Quote
Bookmarks