Welcome to Dream.In.Code
Become a Java Expert!

Join 149,513 Java Programmers for FREE! Get instant access to thousands of Java experts, tutorials, code snippets, and more! There are 1,339 people online right now. Registration is fast and FREE... Join Now!




Help pls in my morse code i want it to translate into scanner

 
Reply to this topicStart new topic

Help pls in my morse code i want it to translate into scanner, Please anyone, help pls i want my code to transfer into a scanner

helpMePls
16 Aug, 2007 - 02:39 AM
Post #1

New D.I.C Head
*

Joined: 16 Aug, 2007
Posts: 1


My Contributions
this is my code and it is a javax.swing.*; package all i want is to transfer it into java.util.*; that have a scanner hope you understand pls...


import java.util.*;
import javax.swing.*; //i want this package to be done


public class Morse

{
public static void main(String args[])

{
Scanner scanner = new Scanner (System.in);
String [] y;
y = new String[5];
String display = " ";

for (int x = 0; x < y.length; x++)

{
y = new String[1];

y[x] = JOptionPane.showInputDialog ("Enter the message you want" +x);
System.out.print("Enter value of element" +x);

//y[x] = scanner.nextInt ();
System.out.println("Enter the message you want" +x);
y[x] = "......-...-..---"; //hello

display = display +" " + y[x];

}
JOptionPane.showMessageDialog(null," " + display);
System.out.println(" " + display);
System.out.print(display + " ");

System.exit(0);
}

}

This post has been edited by helpMePls: 16 Aug, 2007 - 02:41 AM
User is offlineProfile CardPM
+Quote Post

n_b
RE: Help Pls In My Morse Code I Want It To Translate Into Scanner
17 Aug, 2007 - 08:03 AM
Post #2

New D.I.C Head
*

Joined: 9 Aug, 2007
Posts: 8


My Contributions
Hi!

First of all, you may want to take advantage of the ["code"]-tag (without the quotes) when submitting code in the forum. It will look like this:

CODE

...
// Your class here.
...

Remember to close the tags properly by using the ["/code"]-tag at the end of your code-section This has the benefit of greatly improving readability icon_up.gif
Now, to your program!

There are a two questions that need to be resolved in order to help you with this:

QUOTE
... it is a javax.swing.*; package all i want is to transfer it into java.util.*; that have a scanner ...

1. Do you mean that you want help with using the Scanner to recieve input from the keyboard, or do you wish to remove all dependencies on the javax.swing package (i.e. making a command-line application) or something completely different that I haven't thought of?

2. Secondly, what is your program supposed to do? As it is right now, all it does is to print "hello" in morse-code a few times and then quits (i.e. do you intend for it to do so?). If I try to make any changes to your program without knowing what it's supposed to do, I will surely fail.

Please answer my queries here, and we'll see what we can do to fix your program.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic
Time is now: 1/7/09 07:56PM

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter

Live Java Help!

Java Tutorials

Reference Sheets

Java Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month