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, 24.06.2019 09:50
Self contained sequences of actions to be performed are? a. expressions b. algorithms c. functions d. formulas
Answers: 1
question
Computers and Technology, 24.06.2019 17:40
Write a program to analyze student’s scores. each student’s id and 4 original test scores are saved in the attached file “student_id_scores.txt”. assume there are exactly 15 students in the class.• the program first opens the file, reads student’s ids and scores from the file and saves them in two arrays: o create a one-dimensional string array “ids” to store the student’s ids.o create a (parallel) two-dimensional int array “scores” to store student’s original test scores. this array has 5 columns, the original 4 test scores should be saved in the first 4 columns, and the last column will be used to save the average score after the calculation in next step.• the program then retrieves test scores from the array “scores”, calculates average score and determines the final letter grade based on the rules in the table below for each student. assume average score is integer value.average score = (score1 + score2 + score3 + score4) / 4average score letter grade90 ~ 100 a80 ~ 89 b70 ~ 79 c60 ~ 70 d0 ~ 60 f• the average score should be saved back in the 5th column of “scores” array.• create a new parallel one-dimensional char array “grades” to save each student’s letter grade.• program also needs to find the number of a, number of b, number of c, number of d and number of f grade. as well as the highest, lowest and average score of the class.• finally, program will display all of the original scores and all results on the computer screen using the format shown as the sample output below.• the program must contain at least the following functions: (1) a function “getscores” to read and store data into “ids” and “scores” arrays.(2) a function “analyzescores” to calculate student’s average score, determine letter grade, get the number of a, b, c, d and f, find the highest, lowest and average score of the class.(3) a function “displayresults” to display all of the results
Answers: 3
question
Computers and Technology, 24.06.2019 20:00
Which element will you include to present numerical on a slide? a: graph b: text c: flowchart d: shapes
Answers: 1
question
Computers and Technology, 25.06.2019 07:50
In addition to the four primary computer operations, today's computers typically also perform functions.
Answers: 1
You know the right answer?
This question involves a class named filetext that represents a text file.
public class filete...
Questions
question
Mathematics, 04.02.2021 03:50
question
Mathematics, 04.02.2021 03:50
question
Law, 04.02.2021 03:50
Questions on the website: 13722359