Add a method to the Searching class to list all the ...
Q1The International Phonetic Alphabet is used for reliable voice communication. The alphabet includes the followingLetterphonetic letterLetterphonetic letterLetterphonetic letterAAlphaJJulietSSierraBBravoKKiloTTangoCCharlieLLimaUUniformDDeltaMMikeVVictorEEchoNNovemberWWhiskeyFFoxtrotOOscarXX-rayGGolfPPapaYYankeeHHotelQQuebecZZuluIIndiaRRomeoWhen speaking words or mixtures of letters and digits the user speaks each individual symbol using an internationally accepted standard phonetic identification. For example, airline pilots communicating with control centres will speak their ‘call-signs’ using the alphabet. Thus, the call-sign EI137 would be spoken as Echo India One Three Seven; JAVA would be Juliet Alpha Victor Alpha.Write the code for a method with the following headerpublic void phonetic(String s)The method is passed a string (you can assume it has letters and digits and spaces only) and it displays the phonetic equivalent of the string. Spaces should be ignored.// Select this line and the next line public void phoneticProcedure(String s) { int pos = 0; String alphabet = "abcdefghijklmnopqrstuvwxyz0123456789"; String[] phoneticAlphabet = { "Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtort", "Golf", "Hotel", "India", "Juliet", "Kilo", "Lima", "Mike", "November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango", "Uniform", "Victor", " Whiskey ", "X-ray", "Yankee", "Zulu", "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"}; for(int i = 0; i < s.length(); i++) { pos = alphabet.indexOf(Character.toLowerCase(s.charAt(i))); if(pos != -1) { System.out.print(phoneticAlphabet[pos]); System.out.print(" "); } else { System.out.print(s.charAt(i)); } } System.out.println(); }// To unhide a solutionQ2Modify your solution to Q1 so that the method returns a string containing the phonetic equivalent instead of displaying it on the screen.// Select this line and the next line public String phoneticFunction(String s) { int pos = 0; String alphabet = "abcdefghijklmnopqrstuvwxyz0123456789"; String[] phoneticAlphabet = { "Alpha", "Bravo", "Charlie", "Delta", "Echo", "Foxtort", "Golf", "Hotel", "India", "Juliet", "Kilo", "Lima", "Mike", "November", "Oscar", "Papa", "Quebec", "Romeo", "Sierra", "Tango", "Uniform", "Victor", " Whiskey ", "X-ray", "Yankee", "Zulu", "Zero", "One", "Two", "Three", "Four", "Five", "Six", "Seven", "Eight", "Nine"}; String phoneticText = ""; for(int i = 0; i < s.length(); i++) { pos = alphabet.indexOf(Character.toLowerCase(s.charAt(i))); if(pos != -1) { phoneticText = phoneticText + phoneticAlphabet[pos] + " "; } else { phoneticText = phoneticText + s.charAt(i); } } return phoneticText; }// To unhide a solutionQ3An array of ints is described as ‘rising’ if each value in the array is greater than its predecessor. The array is described as ‘falling’ if each value is less than its predecessor. Otherwise it is described as ‘undulating’.In other words, if the second value is greater than the first (its predecessor) the remaining values (from the third to the end) must have the same property to categorise the array as rising. Similarly, if the second is less than the first the remaining values (from the third to the end) must have the same property to categorise the array as falling. If neither of these can be established it must be undulating.Provide the code for a function with the following headerpublic int arrayCategory(int[] array)The function is passed an array of ints and function returns 1 if the array is ‘rising’, 2 if the array is ‘falling’ or 3 if it is ‘undulating’. // Select this line and the next linepublic int arrayCategory(int[] a) { int category = 3; int i = 2; if(a.length > 1) { if(a[1] > a[0]) { while(i < a.length && a[i] > a[i-1]) { i++; } if(i == a.length) { category = 1; } } else if(a[1] < a[0]) { while(i < a.length && a[i] < a[i-1]) { i++; } if(i == a.length) { category = 2; } } } return category;}// To unhide a solution ................
................
In order to avoid copyright disputes, this page is only a partial summary.
To fulfill the demand for quickly locating and searching documents.
It is intelligent file search solution for home and business.
Related download
- prelab exercises moore public schools
- this program is supposed to read a lot of strings typed by
- some basic sml examples
- table of contents
- cs 1301 ch 6 handout 1
- visual basic for c programmers
- arrayprioritylist
- c standard template library an introduction
- homework 1 due friday september 23
- add a method to the searching class to list all the
Related searches
- list all the synonyms
- how to add a application to desktop
- how to add a shortcut to desktop
- how to add a app to desktop
- add a line to ggplot
- add a percentage to a number
- add a program to startup list
- add an icon to the desktop
- apply a method to a list pandas
- add a program to startup windows 10
- how to add a website to desktop
- list all the president