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
Marta_Voda [28]
3 years ago
11

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"
Computers and Technology
1 answer:
lana [24]3 years ago
4 0

Answer:

Explanation:

The following code is written in Java and uses a for loop with a series of IF ELSE statements to check the next and previous characters in a string. Checking to make sure that there are no asterix. If so it adds that character to the String variable output. Which is returned to the user at the end of the method. Two test cases have been created and the output can be seen in the attached image below.

class Brainly {

   public static void main(String[] args) {

       System.out.println(starOut("sm*eilly"));

       System.out.println(starOut("ab**cd"));

   }

   public static String starOut(String str) {

       String output = "";

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

           if ((i != 0) && (i != str.length()-1)) {

               if ((str.charAt(i-1) != '*') && (str.charAt(i+1) != '*') && (str.charAt(i) != '*')) {

                   output += str.charAt(i);

               }

           } else {

               if ((i == 0) && (str.charAt(i) != '*') && (str.charAt(i+1) != '*')) {

                   output += str.charAt(i);

               } else if ((i == str.length()-1) && (str.charAt(i) != '*') && (str.charAt(i-1) != '*')) {

                   output += str.charAt(i);

               }

           }

       }

       return output;

   }

}

You might be interested in
Identify 3 ways mobile phone could be used to contact a bank apart from making a phone call to the bank
Zepler [3.9K]

Answer:

1. Email

2. Website

3. Customer service

8 0
3 years ago
Recording relative positions should reduce total programming time true or false
Svet_ta [14]

This is true. Recording relative positions in most cases will reduce total programming time and make it over all more efficient.

4 0
3 years ago
What is the operation of an earth leakage tester
Vladimir [108]

In any electrical installation, some current will flow through the protective ground conductor to ground. This is usually called leakage current. Leakage current most commonly flows in the insulation surrounding conductors and in the filters protecting electronic equipment around the home or office. So what's the problem? On circuits protected by GFCIs (Ground Fault Current Interrupters), leakage current can cause unnecessary and intermittent tripping. In extreme cases, it can cause a rise in voltage on accessible conductive parts. 


5 0
3 years ago
Write a method named showChar. The method should accept two arguments: a reference to a String object and an integer. The intege
matrenka [14]

A complete program with the method ShowCar:

import java.util.Scanner; // header file

public class ShowChar

{

public static void main(String[] args)

{

String lnOfText;

int i;

Scanner input = new Scanner(System.in);

System.out.print("Enter a line of text:");

lnOfText = input.nextLine();

System.out.print(" Enter your index: ");

i = input.nextInt();

show_Char(lnOfText,i);

}

public static void show_Char(String str_a, int i)

{

System.out.print(str_a.charAt(i));

}

}

In this program, both the inputs ie. a sentence or line of text as well as the index position is obtained. A method is written to find the string at that particular position. Finally the method prints that character at the particular index.

5 0
3 years ago
The set of Visual Basic instructions that tells an object how to behave after an action by the user (such as clicking a button)
alexdok [17]

Answer:

Event procedure

Explanation:

Whenever a user perform certain action, such as press a button on the keyboard or click the mouse, etc. such action are called an event. when an event occurs, Visual Basic looks for BASIC instructions to tell the object in the program how to behave to the user event. The Visual Basic instructions that responds to this specific event is called an event procedure.

7 0
3 years ago
Other questions:
  • What does N represent when analyzing algorithms?
    15·1 answer
  • Why do clocks tick-toc?
    5·2 answers
  • When a defendant pleads guilty to one offense just to have another offense dropped, this is what type of plea bargain
    12·2 answers
  • Which component of the windows desktop allows you to retrieve files that have recently been deleted?
    11·1 answer
  • True or False: When you share something on a friend’s Timeline, only that friend can see it.
    5·2 answers
  • How have productivity programs improved the professional lives of people? (check all that apply)
    8·2 answers
  • How does a typewriter involve math and science?
    10·2 answers
  • Are to print or find<br> the sum<br> 5 numbers<br> of<br> using flow chart
    6·1 answer
  • How many pounds must a sand bag weigh to test if a safety net can absorb the proper amount of force? A. 150 lbs. B. 200 lbs. C.
    6·1 answer
  • Explain 3 categories of plagiarism​
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!