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
mariarad [96]
3 years ago
5

Return a version of the given string, where for every star (*) in the string the star and the chars immediately to its left and

right are gone. So "ab*cd" yields "ad" and "ab**cd" also yields "ad".
starOut("ab*cd") → "ad"

starOut("ab**cd") → "ad"

starOut("sm*eilly") → "silly


Provided statement:


public String starOut(String str) {


//code goes here


}
Computers and Technology
1 answer:
wariber [46]3 years ago
3 0

Answer:

// class definition Solution

public class Solution {

   // main method to begin program execution

   public static void main(String args[]) {

       // the starOut method is called with argument

       starOut("ab*cd");

       starOut("ab*cd");

       starOut("sm*eilly");

   }

   

   // the starOut method is declared and it returns a string

   // it receive a string as the argument

   public static String starOut(String str) {

       // The index of the star is assigned to starIndex

       int starIndex = str.indexOf("*");

       // Index of character before star is known

       int charBeforeStar = starIndex - 1;

       // Index of character after star is known

       int charAfterStar = starIndex + 1;

       // The newString is declared empty

       String newString = "";

       // loop through the string

       for (int i =0; i < str.length(); i++){

           // if i is either of the following index, the loop continue

          // without concatenating with the newString

           if (i == charBeforeStar || i == charAfterStar || i == starIndex){

               continue;

           }

           // the new string is concatenated with a character

           newString += str.charAt(i);

       }

       

   // the new string is printed

       System.out.println(newString);

       // the newString is returned

       return newString;

   }

}

Explanation:

The code logic is stated in the comment inside the code.

You might be interested in
Discuss two things you want to know about driving
Zigmanuir [339]

always stay on the right side

never text and drive


3 0
3 years ago
________ is used to enter the results of a CBC into the computer system.pharmacy system.laboratory system.order entry/results re
podryga [215]

Answer:

laboratory system.

Explanation:

4 0
2 years ago
An important piece of a project is past due date.
bixtya [17]
Budget and time is the answer
4 0
3 years ago
Read 2 more answers
Line spacing refers to the amount of space between each line in a paragraph
Citrus2011 [14]

Answer:

yes sir, its just the format of the paragraphs

4 0
3 years ago
Read the following code:
sergejj [24]

Answer:

0

1

2

3

4

5

Explanation:

The loop first prints when n is still 0, so 0 is in the list.

The loop still executes when n = 5, so 5 must also be in the list.

6 0
3 years ago
Other questions:
  • Interpersonal skills are extremely important in production management. true or false
    10·1 answer
  • A 6.7 kg object moves with a velocity of 8 m/s. What's its kinetic energy?
    6·2 answers
  • What happens when a filter is applied to a database?
    13·1 answer
  • 23+ Composition refers to
    11·1 answer
  • WAP to print given series by using sub procedure 2,3,5,8,13,...........,20th term.​
    6·1 answer
  • Major characteristics of the bus in computer architecture​
    8·1 answer
  • 1. Tracy is studying to become an esthetician. Give three reasons why she needs to have a thorough
    11·1 answer
  • when you enter a url, you’re creating a(n) ____ link, which is the full and complete address for the target document on the web.
    9·1 answer
  • which option dexcribes a situation when asexual reproduction would be more advantageous to an organism?
    14·1 answer
  • Trying to make the baseplate red and turn off can collide then the game waits 5 seconds and turns on can collide, making the bas
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!