subject

Write the Java code to keep track of two arrays: a list of names and a list of secret numbers. Each position in the name array refers to a person whose secret number is stored in the corresponding position of the secret number array. For instance, if the names array contains Alice, Charlie, and Bob and the secret numbers are 42, 111, and 12 (in those orders), then Charlie’s secret number is 111. The program should ask the user how many names will be entered, create a String array reference variable and array object of the appropriate length, then allow the user to enter enough names to fill the array. An integer array reference variable and array object should also be created with the the same size with all values initialized to 1. The secret numbers for each person will be computed by combining the results of the following methods: • A public static int method that accepts a String formal parameter, computes the square root of the String’s length, and returns the ceiling (i. e., Math. ceil) of the value. The actual parameter sent to this method must be a name from the array.
• A public static int method that accepts two Strings as formal parameters. This method computes and returns the number of consonants in common between the two Strings, ignoring upper-case and lower-case. (Hint: Count how many of each of the 19 consonants are in both Strings using two counting arrays, then check how many positions in both counting arrays are non-zero.) Should there be no Strings in common, the number one (1) is returned. One actual parameter sent to this method must be a name from the array, and the other is left up to the student.
• A public static int method that accepts one integer and one String as formal parameters. Retrieve the character in the String parameter at the position indicated by the integer parameter. The character is then cast to an integer and returned to the calling method. Should the integer be an invalid position for the given String, the number one (1) is returned. The String actual parameter sent to this method must be a name from the array, and the integer’s value is left up to the student. Include at least two ways to combine the results of each method above to produce a secret number. Allow the user to choose which combination of methods to apply. The same combination may be used for each name in a program execution. An example which multiplies the three results is given below. The names and secret numbers should then be printed using the following method: A public static void method that accepts a String array and an integer array as formal parameters and prints the values in the order given.

ansver
Answers: 3

Another question on Computers and Technology

question
Computers and Technology, 22.06.2019 14:20
Consider a byte-addressable computer with 16mb of main memory, a cache capable of storing a total of 64kb of data and block size of 32 bytes. (a) how many bits in the memory address? (b) how many blocks are in the cache? (c) specify the format of the memory address, including names and sizes, when the cache is: 1. direct-mapped 2. 4-way set associative 3. fully associative
Answers: 2
question
Computers and Technology, 23.06.2019 00:30
If joey was single and his taxable income was $9,500, how much would he pay in taxes each year?
Answers: 1
question
Computers and Technology, 23.06.2019 11:00
Sports and entertainment class, your goal is to increase attendance and make a profit for a game by getting your team on a winning track with total salaries less than $3,000,000
Answers: 3
question
Computers and Technology, 23.06.2019 19:00
This question involves a class named textfile that represents a text file. public class textfile { private string filename; private string filename; private arraylist words; // constructors not shown // postcondition: returns the number of bytes in this file public int filesize() { } // precondition: 0 < = index < words.size() // postcondition: removes numwords words from the words arraylist beginning at // index. public void deletewords(int index, int numwords) { } // precondition: 0 < = index < = words.size() // postcondition: adds elements from newwords array to words arraylist beginning // at index. pub lic voidaddwords(int index, string[] newwords) { } // other methods not shown } complete the filesize() method. the filesize() is computed in bytes. in a text file, each character in each word counts as one byte. in addition, there is a space in between each word in the words arraylist, and each of those spaces also counts as one byte. for example, suppose the words arraylist stores the following words: { mary had a little lamb; its fleece was white as snow. } the filesize() method would compute 4 + 3 + 1 + 6 + 5 + 4 + 6 + 3 + 5 + 2 + 5 as the sum of the lengths of each string in the arraylist. the value returned would be this sum plus 10, because there would also be 10 spaces in between the 11 words. complete the filesize() method below: // postcondition: returns the number of bytes in this file public int filesize() { }
Answers: 1
You know the right answer?
Write the Java code to keep track of two arrays: a list of names and a list of secret numbers. Each...
Questions
question
History, 19.01.2020 06:31
question
Geography, 19.01.2020 06:31
question
Mathematics, 19.01.2020 06:31
Questions on the website: 13722361