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
The product of two integers is -180 if one of them is 12 find the other​
astraxan [27]

The answer is -15. This because 12 * 15 = 180 so in order to make it negative one of the integers has to be negative and since 12 is given you have to make 15 negative.

6 0
3 years ago
Write a program that reads the lengths of the sides of a triangle from the user. Compute the area of the triangle using Heron's
slamgirl [31]

Answer:

The java program is as follows.

import java.util.Scanner;

import java.lang.*;

public class Area

{

   //variables to hold the values

   static double a, b, c;

   static double s;

   static double area;

public static void main(String[] args) {

    //scanner class object created

    Scanner sc = new Scanner(System.in);

 System.out.print("Enter the first side: ");

 a=sc.nextInt();

 System.out.print("Enter the second side: ");

 b=sc.nextInt();

 System.out.print("Enter the third side: ");

 c=sc.nextInt();

 s=(a+b+c)/2;

 //function of Math class used

 area = Math.sqrt( s*(s-a)*(s-b)*(s-c) );

 //result displayed with 3 decimal places

 System.out.printf("The area of the triangle is %.3f", area);  

}

}

OUTPUT

Enter the first side: 1

Enter the second side: 1

Enter the third side: 1

The area of the triangle is 0.433

Explanation:

1. The variables to declare the three sides of the triangle, the semi-perimeter and the area of the triangle are declared with double datatype. All the variables are declared at class level and hence, declared with keyword, static.  

2. Inside main(), an object of the Scanner class is created.

Scanner sc = new Scanner(System.in);

3. Using the Scanner class object, user input is taken for all the three sides of the triangle.

4. Following this, the semi-perimeter is computed as shown.

s=(a+b+c)/2;

5. The area of the triangle is computed using the given formula which is implemented as shown.

area = Math.sqrt( s*(s-a)*(s-b)*(s-c) );

6. The sqrt() method of the Math class is used while computing the area of the triangle.

7. The area is displayed with three decimals. This is done using the printf() method as shown.

System.out.printf("The area of the triangle is %.3f", area);

8. The program is saved with the same name as the name of the class having the main() method.

9. The class having the main() method is always public.

3 0
3 years ago
What is the most significant result based on the development of windmills and water wheels?
daser333 [38]
Power both wind mills and water wheels produced power which was used for textile factories ect
6 0
3 years ago
Alice's public key, and sends back the number R encrypted with his private key. Alice decrypts the message and verifies that the
Agata [3.3K]

There are different kinds of keys. The identities of Alice and Bob are verified in this protocol.

<h3>What is public and private key in SSL?</h3>

These keys are known to be a kind of related pair of text files and they are often made together as a pair if one makes their Certificate Signing Request (CSR).

Note that the private key is different file that is often used in the encryption/decryption of data so as to sent a file between one's server and the connecting clients.

Learn more about  public/private key from

brainly.com/question/8782374

3 0
2 years ago
A host wants to send a message to another host with the IP address 115.99.80.157. IP does not know the hardware address of the d
Darya [45]

Answer: ARP ( Address Resolution Protocol)

Explanation:

 The address resolution protocol is is one of the type transmission protocol that helps in determining the address of the MAC (Media access control) layer and the IPV4 address.

  • It is basically use for resolving the given IP address by using the hardware and the media access control in the network interface.
  • The main function of the ARP is that it typically used the MAC address for identifying the various types of mode in the network.
  • It is used the ARP format in the form of packet structure for transmitting the message from one place to another in the local network.    

  Therefore, the host is using the address resolution protocol for discovering the MAC address.  

3 0
3 years ago
Read 2 more answers
Other questions:
  • The set of specific, sequential steps that describe exactly what a computer program must do to complete the work is called a(n)
    10·2 answers
  • When you're working with a word processing document and you press the del key, what happens?
    5·1 answer
  • Which table option enables you to combine the contents of several cells into one cell?
    9·2 answers
  • I have to writea piece of code to calculate the factorial of somewhat large numbers so the long long type won't suffize, so usin
    7·1 answer
  • The Springfork Amateur Golf Club has a tournament every weekend. The club president
    7·1 answer
  • Kandi recently started working at new job and must become familiar with her computer. If she would like to view what software ha
    12·1 answer
  • Codehs dartboard 3.12.4
    9·1 answer
  • Which of the following describes a characteristic of organic light-emitting diodes (OLEDs) used in clothing?
    6·2 answers
  • what is the name of the program that enables the device and operating system to communicate with each other?
    7·1 answer
  • What type of attack occurs when the threat actor snoops and intercepts the digital data transmitted by the computer and resends
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!