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
Show what this program prints. Be exact and complete. Can you explain the behavior of each print statement? 1 2 3 4 5 6 7 public
KengaRu [80]

Answer:

39 + 3

42

393

Explanation:

In this line System.out.println("39 + 3"), the quotation marks are used to delimit a string, then when printed in the console the string is printed as-is.

In the next line: System.out.println(39 + 3), without the quotation marks, the 39+3 is treated as a normal addition and prints the result of the operation.

In the last line printed with the code System.out.println("39" + 3,; the symbol + is used to concatenate the string 39 with the number 3, since the string has no spaces they are printed together.

3 0
3 years ago
Differentiate between the broadcasting and telecommunication
dexar [7]
Telecommunication over fixed lines is called point-to-point communication because it is between one transmitter and one receiver. Telecommunication through radio broadcasts is called broadcast communication because it is between one powerful transmitter and numerous low-power but sensitive radio receivers.
6 0
3 years ago
pLZ PLZ PLZ HELP I HAVE SO MANY MISSING ASSINMENTS. why is physical security so important and necessary for both personal users
jeka57 [31]
Physical security is important because a physical attack is perhaps the most fundamental kind of attack. ... Using a floppy drive or CD-ROM drive on a machine that does not support good BIOS security. Damage to or theft of important machine components, especially those that store data. Theft of an entire machine
7 0
3 years ago
What's the difference between an exe file and an msi file? check all that apply.
motikmotik

An EXE file is an executable that may have an MSI file as one its help; An executable or EXE file can "wrap" an MSI file, which is used by the Windows Installer to guide the building process of an application.

MSI files are utilized by the Windows Installer to control how your application is installed.

<h3>What is the difference between an EXE file and MSI file?</h3>

The main difference between the two attachments is their purpose. EXE is used mainly to indicate that the file is an executable one.

In comparison, MSI indicates that the file is a Windows installer. While an MSI is operated only with installers, this is not the case with EXE.

To learn more about EXE file, refer

brainly.com/question/28146265

#SPJ4

7 0
2 years ago
What would the output be of print(3 ** 2)
trapecia [35]
-3–2 I think orange brown green green orange green brown orange brown
4 0
3 years ago
Other questions:
  • Kylie has created some code designed to keep track of information about employees at a company. The code will be used by the com
    6·1 answer
  • Sally is editing her science report about living things. She needs to copy a paragraph from her original report.
    15·2 answers
  • What is a good technological design?
    13·1 answer
  • Generate a row vector b=[1 2 3 4 5 6 7 8 9 10] using linspace function, give the commands and show print-screen of the result.
    11·1 answer
  • Actors,narratirs,and other people whi appear in video programs collectively called what?
    15·1 answer
  • What is the device that is non-volatile sometime called external memory?<br>​
    15·1 answer
  • Write a program that keeps asking the user for new values to be added to a list until the user enters 'exit' ('exit' should NOT
    10·1 answer
  • Write c++ program from 1to 100 to find prime numbers using statement.<br><br>please help me​
    15·1 answer
  • When documenting one author in reference in a text, which is correct?.
    7·1 answer
  • What is a presentation program? Name any<br> presentation programs.
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!