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

Other questions on the subject: Computers and Technology

image
Computers and Technology, 22.06.2019 22:40, shaylawaldo11
Write a program that defines symbolic names for several string literals (chars between quotes). * use each symbolic name in a variable definition. * use of symbolic to compose the assembly code instruction set can perform vara = (vara - varb) + (varc - vard); ensure that variable is in unsigned integer data type. * you should also further enhance your symbolic logic block to to perform expression by introducing addition substitution rule. vara = (vara+varb) - (varc+vard). required: debug the disassembly code and note down the address and memory information.
Answers: 3
image
Computers and Technology, 23.06.2019 00:30, devenybates
Which one of the following is the most accurate definition of technology? a electronic tools that improve functionality b electronic tools that provide entertainment or practical value c any type of tool that serves a practical function d any type of tool that enhances communication
Answers: 1
image
Computers and Technology, 23.06.2019 07:00, bskyeb14579
Why is investing in a mutual fund less risky than investing in a particular company's stock? a. mutual funds only invest in blue-chip stocks. b. investments in mutual funds are more liquid. c. mutual funds hold a diversified portfolio of stocks. d. investments in mutual funds offer a higher rate of return.
Answers: 2
image
Computers and Technology, 23.06.2019 21:20, nathanfletcher
In microsoft word, when you highlight existing text you want to replace, you're in              a.  advanced mode.    b.  automatic mode.    c.  basic mode.    d.  typeover mode
Answers: 1
You know the right answer?
This question involves a class named filetext that represents a text file.
public class filete...

Questions in other subjects: