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
If known vulnerabilities in software are entry points for an attacker, why are the software vulnerabilities not corrected before
Evgesh-ka [11]

Answer:

we dont knoqw

Explanation:

7 0
2 years ago
What can be controlled through IoT? Choose four answers.
BaLLatris [955]

Answer:

Door locks

Light switches

Security cameras

Thermostat

Explanation:

IoT is internet of things that means network of different things that are interconnected through internet and make the decision with the help of Electronic sensors. The sensor sense the data from environment at different times and send this to the cloud (that may be the server). On the basis of this data different devices such as door looks, light switches, security cameras and thermostat take decisions with the help of controllers and change their current state.

<u>For Example</u>

In case of door look, there may be sensor that is sensing the finger prints of the user and after recognizing the person the door will be unlock. If unauthenticated user will try to open the lock a message has been sent to concerned. The training data of the the authorized persons is saved on the cloud, whenever someone tries to access, the data from sensor and cloud send to controller for making comparison and decision. So we can say that Door lock can be controlled IoT.

In case of light switches, there are few sensor available to sense the intensity of life. Different training values of that sensors are stored on the cloud. Whenever these sensors sense the light intensity, they send the data to the cloud contentiously, whenever the data match with darkness intensity, a signal has been send from controller to the switch to ON the lights.

Same as in cameras and Thermostat both are sending data to the cloud and controller. With the help of different image processing techniques and sensor camera will take the decision related to face recognition. Thermostat devices are also on and off by variation of temperature.

7 0
4 years ago
Bluetooth headphones does or do not use wireless data transmission
galben [10]

Answer:

To put it simply: no, using Bluetooth won't affect your cellular data in any way. Bluetooth works using short-range radio waves, not an internet connection. This means that Bluetooth will work anywhere you have two compatible devices — you don't need any sort of data plan, or even a cellular connection.

7 0
3 years ago
PLEASE I NEED HELP ASAP PLEASE PLEASE!!!
aniked [119]

Answer:

Following are the program in the Python Programming Language

#set variables to 0

positive_sum=0  

negative_sum=0  

#print message  

print("Enter 0 to terminate")  

#set the while loop  

while(True):  

#get input from the user  

num=float(input("Enter positive or negative numbers: "))  

#set if statement to check condition  

if(num==0):  

  break  

elif(num>0):  

  positive_sum+=num  

else:  

  negative_sum+=num  

#print output with message  

print()  

print("sum of positive numbers: ", positive_sum)  

print("sum of negative numbers: ", negative_sum)  

Output:  

Enter 0 to terminate  

Enter positive or negative numbers: 1  

Enter positive or negative numbers: 3  

Enter positive or negative numbers: 5  

Enter positive or negative numbers: -7  

Enter positive or negative numbers: -2Enter positive or negative numbers: 0  

sum of positive numbers:  9.0  

sum of negative numbers:  -9.0

Explanation:

Here, we set two integer data type variables "positive_sum", "negative_sum" and initialize to 0.

Then, we set the while infinite loop inside the loop.

Set a variable "num" and get input from the user in it.

Set the if conditional statement and check condition the variable "num" is equal to 0 then, loop will terminate.

Set the elif statement and check condition the variable "num" is greater than 0 then, add that input and store in the variable "positive_sum"

Otherwise, add that input and store in the variable "negative_sum".

Finally, we print the output with the message.

8 0
2 years ago
A friend was just promoted to a new job that requires part-time travel, and he has also been promised a new laptop after his fir
frutty [35]

Answer:

Well, I would definitely advise him to buy USB hubs.

Explanation:

USB hub is a device that can give additional USB slot for the user just by consuming one single slots. In recent years, USB hubs can contain more than 9 slots with different variety, including HDMI and DVI that is required by this particular friend.

Using this device will make it easier to plug in and plug out all the devices he wants to his laptop since it all connected to one single hub.

Since he only has the budget under 100$ , Dell DA300 6-in-1 USB-C Hub could be a good option for Him.

6 0
3 years ago
Other questions:
  • NEED HELP AGAIN
    11·2 answers
  • Use the SAS dataset insure to create a dataset, work.insure10, that (a) only reads in the variables Name, Policy, Company, PctIn
    9·1 answer
  • What is wrong with this line of python code
    9·1 answer
  • What is the difference between requirements and controls in the security process? Give examples of each.
    11·1 answer
  • Suppose I create a new kind of Java object, called "Kangaroo". Further suppose that at any given time, all instances of this new
    6·1 answer
  • Which of the following is NOT one of the Big 3 Google Applications that we discussed?
    9·2 answers
  • Write a grammar for the language consisting of strings that have n copies of the letter a followed by the same number of copies
    11·1 answer
  • who thinks homework is anoyying? (freddy randomly started thinking scince he was the leader he caould start acting like a teache
    8·2 answers
  • Which is a guideline for conducting technical reviews?
    12·1 answer
  • All mortgage companies are willing to loan anyone money regardless of credit scores. True or false?
    12·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!