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
In this unit, you developed your skills at coding in Python. In this lab, you will put those skills to work by creating a progra
Arturiano [62]

Answer:

Don't forget to close any parentheses you open. Other then that everything looks fine, I just polished it a little bit

Explanation:

name = input("What is your first name? ")

print("Hello", name)

age = int(input("How old are you? "))

print("In 10 years you will be", (age+10))

print("In 20 years you will be", (age+20))

print("5 years ago you were", (age-5))

5 0
2 years ago
Read 2 more answers
If you could represent yourself with one object from your home what would it be ?
user100 [1]

Answer:

cross

bc im religous and stuff (0_0)

8 0
2 years ago
Read 2 more answers
Identify three errors in this HTML code snippet:
Kazeer [188]

I have annotated the errors in the picture.

<em />

<em>Hope this helps :)</em>

5 0
1 year ago
Read 2 more answers
A company has recently learned of a person trying to obtain personal information of employees illegally. According to which act
Juli2301 [7.4K]

Answer

Digital Millennium Act

Explanation

The Digital Millennium Copyright Act  is a United States copyright law that implements two  treaties of the World Intellectual Property Organization . The aim of this ACT is to protect the rights of both copyright owners and consumers. The law complies with the World Intellectual Property Organization  Copyright. The law has two basic functions. First, it protects copyright owners by providing them with a mechanism to enforce their rights without having to directly sue the infringer

7 0
2 years ago
Read 2 more answers
NumA=2<br> for count range (5,8)<br> numA=numA+count <br> print(numA)
love history [14]

Answer:

for count in range (5,8): numA=numA+count print(numA)

Explanation:

7 0
2 years ago
Other questions:
  • he fundamental building block in every Hypertext Markup Language (HTML) document is the _____ tag, which marks a component in th
    7·1 answer
  • Fact Pattern: A sales transaction record designed to contain the information presented below. Column Information 1-10 Customer a
    13·1 answer
  • What is 450 g of flour a measure of?
    11·1 answer
  • Which two statements are true about the Data Sync functionality? (Choose two.)
    15·1 answer
  • DES: Group of answer choices A) is a commonly used symmetric encryption B) algorithm that was developed in the mid-C) 1970s was
    6·1 answer
  • Which of the following is not hardware? wireless network router X-box 360 game controller virus scanner flat-panel monitor
    5·2 answers
  • A system is composed of four parts, J, K, L, and M. All four must function for the system to function. The four component reliab
    6·1 answer
  • You can align controls in the report design window using the align button on the report design tools ____ tab.
    8·1 answer
  • • Comments are blank which can be blank entered into documents
    5·1 answer
  • you want to upgrade your windows 10 professional computer to windows 11 professional. you begin by checking the hardware and dis
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!