hello peoples, i have made my first program that is over 50 lines of code and i would like to share it! WARNING: you must create and configure morsecode.txt to run the program correctly :-\
[code]/**
-
This programs translates into morse code.
/
import java.util.ArrayList;
import java.util.Scanner;
import java.awt.;
import java.io.File;
import java.io.PrintWriter;
import java.io.IOException;
public class MorseCode {public static void main(String[] args) throws IOException
{
Scanner in2 = new Scanner(new File(“morsecode.txt”));
ArrayList morse = new ArrayList();while(in2.hasNext()) { morse.add(in2.next()); } in2.close(); String [] letters = {"a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"}; System.out.print("Type a sentence with no punctuation... "); Scanner in = new Scanner(System.in); String user = in.next(); ArrayList<String> userLetters = new ArrayList<String>(); for (int i = 0; i < user.length(); i++) { userLetters.add("" + user.charAt(i)); } System.out.println(); System.out.println(); for (int i = 0; i <user.length(); i++) { if (user.charAt(i) == 'a') { System.out.print(morse.get(0) + ", "); } if (user.charAt(i) == 'b') { System.out.print(morse.get(1) + ", "); } if (user.charAt(i) == 'c') { System.out.print(morse.get(2) + ", "); } if (user.charAt(i) == 'd') { System.out.print(morse.get(3) + ", "); } if (user.charAt(i) == 'e') { System.out.print(morse.get(4) + ", "); } if (user.charAt(i) == 'f') { System.out.print(morse.get(5) + ", "); } if (user.charAt(i) == 'g') { System.out.print(morse.get(6) + ", "); } if (user.charAt(i) == 'h') { System.out.print(morse.get(7) + ", "); } if (user.charAt(i) == 'i') { System.out.print(morse.get(8) + ", "); } if (user.charAt(i) == 'j') { System.out.print(morse.get(9) + ", "); } if (user.charAt(i) == 'k') { System.out.print(morse.get(10) + ", "); } if (user.charAt(i) == 'l') { System.out.print(morse.get(11) + ", "); } if (user.charAt(i) == 'm') { System.out.print(morse.get(12) + ", "); } if (user.charAt(i) == 'n') { System.out.print(morse.get(13) + ", "); } if (user.charAt(i) == 'o') { System.out.print(morse.get(14) + ", "); } if (user.charAt(i) == 'p') { System.out.print(morse.get(15) + ", "); } if (user.charAt(i) == 'q') { System.out.print(morse.get(16) + ", "); } if (user.charAt(i) == 'r') { System.out.print(morse.get(17) + ", "); } if (user.charAt(i) == 's') { System.out.print(morse.get(18) + ", "); } if (user.charAt(i) == 't') { System.out.print(morse.get(19) + ", "); } if (user.charAt(i) == 'u') { System.out.print(morse.get(20) + ", "); } if (user.charAt(i) == 'v') { System.out.print(morse.get(21) + ", "); } if (user.charAt(i) == 'w') { System.out.print(morse.get(22) + ", "); } if (user.charAt(i) == 'x') { System.out.print(morse.get(23) + ", "); } if (user.charAt(i) == 'y') { System.out.print(morse.get(24) + ", "); } if (user.charAt(i) == 'z') { System.out.print(morse.get(25) + ", "); } if (user.charAt(i) == '1') { System.out.print(morse.get(26) + ", "); } if (user.charAt(i) == '2') { System.out.print(morse.get(27) + ", "); } if (user.charAt(i) == '3') { System.out.print(morse.get(28) + ", "); } if (user.charAt(i) == '4') { System.out.print(morse.get(29) + ", "); } if (user.charAt(i) == '5') { System.out.print(morse.get(30) + ", "); } if (user.charAt(i) == '6') { System.out.print(morse.get(31) + ", "); } if (user.charAt(i) == '7') { System.out.print(morse.get(32) + ", "); } if (user.charAt(i) == '8') { System.out.print(morse.get(33) + ", "); } if (user.charAt(i) == '9') { System.out.print(morse.get(34) + ", "); } if (user.charAt(i) == '0') { System.out.print(morse.get(35) + ", "); } if (user.charAt(i) == ' ') { System.out.print(""); } } in.close();
}
}[/code]
and here is what i WANTED to make :’( http://www.lagmonster.org/utilities/morse/
Also, i have no clue how to config the txt file so don’t ask :-X
Here is what i have to say for myself: -.-- . … / - … .- - / .-- .- … / …- . .-. -.-- / -… …- – -… / — …-. / – . / … — / .-- … .- -