1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Georgia [21]
4 years ago
3

Write a method markLength4 that takes an ArrayList of Strings as a parameter and that places a string of four asterisks "****" i

n front of every string of length 4. For example, suppose that a variable called list contains the following values: {"this", "is", "lots", "of", "fun", "for", "every", "Java", "programmer"} And you make the following call: markLength4(list); then list should store the following values after the call: {"****", "this", "is", "****", "lots", "of", "fun", "for", "every", "****", "Java", "programmer"} Notice that you leave the original strings in the list, "this", "lots", "Java", but include the four-asterisk string in front of each to

Computers and Technology
1 answer:
WARRIOR [948]4 years ago
8 0

Answer:

kindly check explainations for code output.

Explanation:

The program code below.

import java.util.ArrayList;

class MarkLength4

{

public static void main(String args[])

{

ArrayList s1=new ArrayList();

s1.add("this");s1.add("is");s1.add("lots");

s1.add("of");s1.add("fun");s1.add("for");

s1.add("every");s1.add("java");

s1.add("programmer");

int i;

System.out.println("Before Marking Length 4:");

System.out.print("s1=[");

for(i=0;i<s1.size();i++)

{

System.out.print(s1.get(i)+" ");

}

System.out.print("]\n");

markLength4(s1);

System.out.println("After Marking Length 4:");

System.out.print("s1=[");

for(i=0;i<s1.size();i++)

{

System.out.print(s1.get(i)+" ");

}

System.out.print("]\n");

}

public static void markLength4(ArrayList s1)

{

ArrayList t1=new ArrayList();

int size=s1.size();

int i;

for(i=0;i<size;i++)

{

String t=s1.get(i).toString();

if(t.length()==4)t1.add("****");

t1.add(s1.get(i));

}

s1.clear();

s1.addAll(t1);

}

}

Check attachment for output.

You might be interested in
Advantages of Linux include_____.
Assoli18 [71]

Answer:

The ability to tweak an application, and i think security. I've barely scratched the surface of linux so my answer may not be 100% accurate

Explanation:

8 0
3 years ago
Which two sentences uses the colon correctly?
faust18 [17]
You much list something after a colon.
For example
Kaylina's bag included:
Food,Books,Makeup,and a brush.
5 0
3 years ago
Design the logic for a program that allows a user to enter 20 numbers, then displays each number and its difference from the num
Svetach [21]

Answer:

Logic for a program

Explanation:

//Here ind = index

//declare the number

number ind

number sum

number avg

number SIZE = 20

number num[SIZE] = {0,0,0,0,0,0,0,0,0,0 ,0,0,0,0,0,0,0,0,0,0}

getReady()

while ind < SIZE

getNumbers()

stop

getReady()

ind = 0

sum = 0

return

getNumbers()

cout<< “Enter a number for position ”, ind

input numbers[ind]

sum = sum + numbers[ind]

ind = ind + 1

return ;

finishUp()

avg = sum/SIZE

ind = 0

while ind < SIZE

output numbers[ind], avg – numbers[index]

ind = ind + 1

return

Modify the program in 2a

number index

number sum

number avg

number actualSize

number SIZE = 10

number number[SIZE] = 0

7 0
4 years ago
The algorithm for solving the problem of average of five (5) numbers​
PilotLPTM [1.2K]

Answer:

Explanation:

Denote the five numbers as a, b, c, d and e.

The average is:

(a + b + c + d +e) ÷ 5.

Easily:

Learn how to do input and output operations in your programming language of choice.

Learn what average is (see Arithmetic mean - Wikipedia)

Learn how to code arithmetic operations in your PL of choice.

Put all that together and code the program.

Oh, did you expect the code snippet? Sorry, I don’t do peoples’ homework for them on principle. Homework is for you to learn something. If you can’t be bothered, accept that you’ll fail your class. If you want to pass, LEARN.

3 0
3 years ago
Write a Java program that reads an 8-bit binary number from the keyboard as a string and then converts it into decimal. For exam
cestrela7 [59]

Answer:

public class Brainly

{

 public static void main(String[] args)

 {

   BinaryConverter conv = new BinaryConverter();

   String binStr = "01001101";

   System.out.print(binStr + " in decimal is "+conv.BinToDec(binStr));

 }

}

public class BinaryConverter

{

 public int BinToDec(String binStr)

 {

   int d = 0;

   while(binStr.length() > 0)

   {

     d = (d << 1) + ((binStr.charAt(0) == '1') ? 1: 0);

     binStr = binStr.substring(1);

   }

   return d;

 }

}

Explanation:

The program "eats" the string from left to right, and builds up the integer representation in variable "d" on the go. While there are digits left, it shifts the previous result to the left and sets the least signficant bit to 1 only if the corresponding string character is a 1.

5 0
3 years ago
Other questions:
  • The _________ check is a type of hardware control that involves adding a "1" or a "0" to the end of every 8 bit byte such that t
    11·1 answer
  • Chevening is looking for individuals with strong professional relationship building skills, who will engage with the Chevening c
    15·1 answer
  • How much electricity is in the human brain? ​
    8·2 answers
  • When might be the best time to start saving for retirement?
    5·2 answers
  • What do you do to add a line or circle to your presentation?
    7·2 answers
  • Edhesive coding practice 3.4​
    12·1 answer
  • Write is an I.P.O cycle? Describe with figure​
    5·1 answer
  • Charles was supposed to present his PowerPoint slides to his classmates in a classroom, but now he has to present in the auditor
    12·2 answers
  • This code --&gt; plt.plot(x,y) is used to draw :
    8·1 answer
  • David plays racing games on his way to work. He uses the analog stick to navigate his vehicle through other artificial intellige
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!