subject

This question involves a class named filetext that represents a text file.
public class filetext
{
private string filename;
private int filebytes;
private arraylist‹string› wordlist; // the contents of the text file
// constructors not shown
// postcondition: calculates the number of bytes in this file and updates
// the instance variable filebytes
public void filesize()
{
}
// precondition: 0 < newwords. length < wordlist. size ()
// postcondition: elements from the newwords array are placed into consecutive
// odd index positions of the wordlist arraylist
// postcondition: the value of filebytes is updated
public void mergewords(string[] newwords)
{
}
// other methods not shown
}
the wordlist arraylist stores the words (tokens) found in a text file. suppose wordlist contains the following elements:
[mary, had, a, little, lamb]
the filesize method; the size of the file is computed in bytes. each character in a word counts as one byte. in addition, there is a space in between each word, and each of those spaces also counts as one byte. for the example above, the filesize method would compute 4 + 3 + 1 + 6 + 4 as the sum of the lengths of each string in the arraylist. the value of filebytes would be this sum plus 4, because there would be 4 spaces in between the 5 words.
for the mergewords method, assume the values for the newwords array are as follows:
{"one", "two", "three"}
after the method has executed, filebytes will have an updated value, and wordlist would contain the following elements:
[mary, one, had, two, a, three, little, lamb]
complete the filesize and mergewords methods below. be sure to include the method headers.

ansver
Answers: 2

Another question on Computers and Technology

question
Computers and Technology, 23.06.2019 17:00
The camera still is bad even with the new iphone xr and especially in low light it is even worst because you can see the pixels more if its in low light. if all you apple customers want apple to fix this then lets fill there feedback with complaints about the
Answers: 1
question
Computers and Technology, 24.06.2019 03:30
Explain the importance of html in web page designing in 20 sentences..
Answers: 1
question
Computers and Technology, 24.06.2019 12:00
Match the function to its purpose. fast worth 50pts.
Answers: 1
question
Computers and Technology, 24.06.2019 13:00
What are some websites that you can read manga (ex: manga rock)
Answers: 1
You know the right answer?
This question involves a class named filetext that represents a text file.
public class filete...
Questions
question
History, 08.10.2020 23:01
question
Geography, 08.10.2020 23:01
question
Spanish, 08.10.2020 23:01
question
Mathematics, 08.10.2020 23:01
Questions on the website: 13722362