Click here to Skip to main content
15,949,686 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
My friend just told me he needs to write a code that translates Morse code to English, and he's really struggling (his teacher showed them the interface for the program, but didn't actually give them the source code for it, which I find really stupid, since you can't really make a program, without making some reference to interface elements such as button and checkboxes). I though I'd try doing it myself, since I like a challenge.

Anyway, so I want the input of the user to be checked character-by-character, which means if someone puts in "Hi", the code won't check for "Hi", but instead for "h" and "i" separately, and then display the Morse code equivalent for both. (upper and lower case don't matter much. Right now, I just want to get the translation down)

How would I do this?

What I have tried:

I have not tried anything yet.
Posted
Updated 12-Jan-17 2:34am
Comments
[no name] 12-Jan-17 8:19am    
https://docs.oracle.com/javase/tutorial/
Denisowator 12-Jan-17 8:24am    
That doesn't really point me into anything. You gave me a link to the main tutorial site, how am I supposed to find what I need to learn?
[no name] 12-Jan-17 8:30am    
You go through the tutorials and learn. We can't teach you programming over the internet and we won't do your or your friends homework for them either.
Jochen Arndt 12-Jan-17 8:37am    
That is the real life of a programmer:
To find what you need (if you did not know it already).

So, if you did not know Java, that link is the starting point.

If you did know Java, think about the problem.
In your case like:
Ok, I have a string and want to process each character in it. Where do I get information?

Answer: Read (or know) Java strings:
https://docs.oracle.com/javase/7/docs/api/java/lang/String.html

So how do I get the single characters from the string?
Solution: Read the above link. There might be functions doing exactly that.
Richard MacCutchan 12-Jan-17 8:24am    
"I though I'd try doing it myself, since I like a challenge."
"I have not tried anything yet."

Do you see an anomaly there?

1 solution

Ask Google these questions:
1. split string to character java
2. upper lower case character java
3. case switch java
For a complete picture, follow the official Trail: Learning the Java Language (The Java™ Tutorials)[^]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900