{"id":132157,"date":"2023-08-20T00:03:36","date_gmt":"2023-08-20T00:03:36","guid":{"rendered":"https:\/\/assignmenttutors.net\/blog\/morse-code-conversion-program-computer-science-homework-help\/"},"modified":"2023-08-20T00:03:36","modified_gmt":"2023-08-20T00:03:36","slug":"morse-code-conversion-program-computer-science-homework-help","status":"publish","type":"post","link":"https:\/\/assignmenttutors.net\/blog\/morse-code-conversion-program-computer-science-homework-help\/","title":{"rendered":"Morse code conversion program | Computer Science homework help"},"content":{"rendered":"<div>\n<p>JAVA\u00a0 for Eclipse<\/p>\n<p>\u00a0<\/p>\n<p>Objective:<\/p>\n<p>The letters of the alphabet A through Z can be represented in Morse code. Each letter is represented by a combination of up to four dots and\/or dashes, as shown below. Use Java to write and run a console-window program that can convert an English message into Morse code or a Morse code message into English. The program must satisfy the following requirements:<\/p>\n<p>Description:<\/p>\n<p>Create a class called\u00a0MorseCode\u00a0that at least has methods with the following signatures:<\/p>\n<ul>\n<li>toMorseCode(char letter)\u00a0&#8211; accepts a single capital letter from the English alphabet and returns an array of 4 characters representing the Morse code equivalent of that letter.<\/li>\n<li>fromMorseCode(char[] arr)\u00a0&#8211; accepts an array of four Morse code characters (each either a dot, a dash, or space) and returns the English letter equivalent.<\/li>\n<\/ul>\n<p>The\u00a0MorseCode\u00a0class will have two static variables:<\/p>\n<ul>\n<li>char[] alphabet\u00a0&#8211; An array of all 26 letters in the alphabet.<\/li>\n<li>char[][] morseCodeAlphabet\u00a0&#8211; an array of arrays of char, storing the morse code entries for all 26 letters of the alphabet.<\/li>\n<\/ul>\n<p>Create a class\u00a0AlphabetException. This class should extend\u00a0Exception, and be used in case the user enters an invalid character in EITHER mode. For example, if the user wants to convert from English to Morse and enters a lower-case letter, your program should throw an\u00a0AlphabetException.<\/p>\n<p>Create a driver class called\u00a0TestMorseCode. At a minimum<\/p>\n<ol>\n<li>The program should print its name<\/li>\n<li>The program should (continually) ask the user to whether the original phrase will be in English or Morse<\/li>\n<li>For each iteration, the program should ask the user for a phrase (either in English or Morse, depending on the previous choice)<\/li>\n<li>For each iteration, the program will print the result of the conversion (either English to Morse or Morse to English)\n<ul>\n<li>If the user enters an invalid character, your program should check for an\u00a0AlphabetException\u00a0and print an appropriate message.<\/li>\n<li>After the error, your program should continue on the next iteration of the main loop (i.e. your program should NOT quit if the user enters an invalid phrase)<\/li>\n<\/ul>\n<\/li>\n<li>Your source code must conform to good programming style, with Javadoc comments on all public methods.<\/li>\n<\/ol>\n<p>Example:<\/p>\n<pre>    Morse Code Conversion Program.&#13;\n    This program reads a phrase in English(or Morse code) and prints its equivalent in Morse code (or English)&#13;\n    Please select one [1-3]:&#13;\n    1: English -&gt; Morse&#13;\n    2: Morse -&gt; English&#13;\n    3: Quit&#13;\n    1&#13;\n    Enter an English phrase:&#13;\n    PARTY ON&#13;\n    .--. .- .-. - -.-- \/ --- -.&#13;\n    Please select one [1-3]:&#13;\n    1: English -&gt; Morse&#13;\n    2: Morse -&gt; English&#13;\n    3: Quit&#13;\n    2&#13;\n    Enter a Morse phrase:&#13;\n    .--. .- .-. - -.-- \/ --- -.&#13;\n    PARTY ON&#13;\n    Please select one [1-3]:&#13;\n    1: English -&gt; Morse&#13;\n    2: Morse -&gt; English&#13;\n    3: Quit&#13;\n    1&#13;\n    Enter an English phrase:&#13;\n    this will cause an error&#13;\n    Letter 't' not in alphabet&#13;\n    Aborting conversion&#13;\n    Please select one [1-3]:&#13;\n    1: English -&gt; Morse&#13;\n    2: Morse -&gt; English&#13;\n    3: Quit&#13;\n    3&#13;\n        <\/pre>\n<p>Conversion Table:<\/p>\n<pre>  A .-      H ....    O ---     V ...-&#13;\n  B -...    I ..      P .--.    W .--&#13;\n  C -.-.    J .---    Q --.-    X -..-&#13;\n  D -..     K -.-     R .-.     Y -.--&#13;\n  E .       L .-..    S ...     Z --..&#13;\n  F ..-.    M --      T -&#13;\n  G --.     N -.      U ..-&#13;\n        <\/pre>\n<p>\u00a0<\/p>\n<p>\u00a0<\/p>\n<p>ADDITIONAL DOC:<\/p>\n<p>\u00a0To save time here is the code for the above table<\/p>\n<pre>    private static char[][]&#13;\n        morseCodeAlphabet = { { \"https:\/\/www.sweetstudy.com\/\" }&#13;\n                            , { '.', '-'           }&#13;\n                            , { '-', '.', '.', '.' }&#13;\n                            , { '-', '.', '-', '.' }&#13;\n                            , { '-', '.', '.'      }&#13;\n                            , { '.'                }&#13;\n                            , { '.', '.', '-', '.' }&#13;\n                            , { '-', '-', '.'      }&#13;\n                            , { '.', '.', '.', '.' }&#13;\n                            , { '.', '.'           }&#13;\n                            , { '.', '-', '-', '-' }&#13;\n                            , { '-', '.', '-'      }&#13;\n                            , { '.', '-', '.', '.' }&#13;\n                            , { '-', '-'           }&#13;\n                            , { '-', '.'           }&#13;\n                            , { '-', '-', '-'      }&#13;\n                            , { '.', '-', '-', '.' }&#13;\n                            , { '-', '-', '.', '-' }&#13;\n                            , { '.', '-', '.'      }&#13;\n                            , { '.', '.', '.'      }&#13;\n                            , { '-'                }&#13;\n                            , { '.', '.', '-'      }&#13;\n                            , { '.', '.', '.', '-' }&#13;\n                            , { '.', '-', '-'      }&#13;\n                            , { '-', '.', '.', '-' }&#13;\n                            , { '-', '.', '-', '-' }&#13;\n                            , { '-', '-', '.', '.' }&#13;\n                            };&#13;\n    private static char[] alphabet = { ' ', 'A', 'B', 'C', 'D'&#13;\n                                     , 'E', 'F', 'G', 'H', 'I'&#13;\n                                     , 'J', 'K', 'L', 'M', 'N'&#13;\n                                     , 'O', 'P', 'Q', 'R', 'S'&#13;\n                                     , 'T', 'U', 'V', 'W', 'X'&#13;\n                                     , 'Y', 'Z' };<\/pre>\n<p>\u00a0<\/p>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>JAVA\u00a0 for Eclipse \u00a0 Objective: The letters of the alphabet A through Z can be represented in Morse code. Each letter is represented by a combination of up to four dots and\/or dashes, as shown below. Use Java to write and run a console-window program that can convert an English message into Morse code or [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-132157","post","type-post","status-publish","format-standard","hentry","category-education"],"_links":{"self":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/132157","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/comments?post=132157"}],"version-history":[{"count":0,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/posts\/132157\/revisions"}],"wp:attachment":[{"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/media?parent=132157"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/categories?post=132157"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/assignmenttutors.net\/blog\/wp-json\/wp\/v2\/tags?post=132157"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}