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
Fallon is a new student on campus. Everywhere she goes, she is asked for her 12-digit student number. To memorize her new studen
makvit [3.9K]

Answer:

chunking

Explanation:

Chunking refers to an approach for making more efficient use of short-term memory by grouping information. Chunking breaks up long strings of information into units or chunks. The resulting chunks are easier to commit to memory than a longer uninterrupted string of information.

8 0
4 years ago
Name the hardware component that performs each of the following functions (1) performs calculation and/or comparisons (2) holds
mariarad [96]
1. The CPU (central processing unit) does the calculations and comparisons that make the computer work. They use millions of transistors to do so.
2. The ROM holds all the programs on the computer. This is most often the "C" drive.
3. The ROM also has the operating system that is used to run the computer.
6 0
3 years ago
A person can receive an electric shock by
trapecia [35]

the answer is C. completing an electrical circuit

4 0
4 years ago
Read 2 more answers
_______ refers to the poitically, religiously, or ideologically motivated use of computers (or related technology) by an individ
Anettt [7]

Answer:

The answer of the following blank is Cyberterrorism .

Explanation:

Cyberterrorism is the violent act by the use of an internet that results in the threat of any important files or the loss of life or the significance of the bodily harms, to achieve an ideological or political gains through the threat or the intimidation.

6 0
3 years ago
When using a direct quotation, which one of the following is not necessary?
ss7ja [257]

Answer:

B

Explanation:

You can't rewrite a source with the writers voice. that makes no sense

6 0
4 years ago
Other questions:
  • Acme Parts runs a small factory and employs workers who are paid one of three hourly rates depending on their shift: first shift
    5·1 answer
  • A. True
    5·1 answer
  • Identify the four basic categories of hardware in a microcomputer system. system unit, modem, ram, and microprocessor system uni
    5·1 answer
  • To add a row labeled "total" to a query design click the ____ button in the show/hide group on the design tab on the ribbon.
    14·2 answers
  • A (n) _____________ chart is represented by a circle divided into portions.
    8·1 answer
  • Which type of address is used at the transport layer to identify the receiving application?
    14·1 answer
  • Which shape denotes a process to be carried out in a flowchart?
    7·2 answers
  • Which of these is a Microsoft certification for system engineers?
    9·1 answer
  • In the mouse properties window you can
    6·1 answer
  • Which of the following statements about content-based filtering is TRUE?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!