Java - 按字符输入扫描? [英] Java - input scanned character-by-character?

查看:55
本文介绍了Java - 按字符输入扫描?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的朋友告诉我他需要编写一个代码,将莫尔斯代码翻译成英文,他真的很挣扎(他的老师向他们展示了该程序的界面,但实际上并没有给他们提供源代码,我发现真的很愚蠢,因为你不能真正制作一个程序,而没有引用一些界面元素,如按钮和复选框)。我虽然自己也尝试过,因为我喜欢挑战。



无论如何,我希望逐个字符地检查用户的输入,这意味着如果有人输入Hi,代码将不会检查Hi,而是分别检查h和i,然后显示两者的莫尔斯代码。 (大小写并不重要。现在,我只想把翻译下来)



我该怎么做?



我尝试了什么:



我还没有尝试过任何东西。

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.

推荐答案

向Google询问以下问题:

1.将字符串拆分为字符java

2.大写小写字符java

3. case switch java

如需完整图片,请按照官方 Trail:学习Java语言(Java™教程) [ ^ ]
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)[^]


这篇关于Java - 按字符输入扫描?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆