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 [7]
3 years ago
10

2. Write a Java program that generates a new string by concatenating the reversed substrings of even indexes and odd indexes sep

arately from a given string. For this code you may use the above method to reverse the string. [10 points] Example #1 Input: abscacd Output: dasaccb Explanation: Substring are: asad, bcc Reversed substrings are: dasa, ccb Output: dasaccb
Engineering
1 answer:
Nana76 [90]3 years ago
4 0

Answer:

  1. public class Main {
  2.    public static void main(String[] args) {
  3.        String testString = "abscacd";
  4.        String evenStr = "";
  5.        String oddStr = "";
  6.        for(int i=testString.length() - 1; i >= 0; i--){
  7.            if(i % 2 == 0){
  8.                evenStr += testString.charAt(i);
  9.            }
  10.            else{
  11.                oddStr += testString.charAt(i);
  12.            }
  13.        }
  14.        System.out.println(evenStr + oddStr);
  15.    }
  16. }

Explanation:

Firstly, let declare a variable testString to hold an input string "abscacd" (Line 1).

Next create another two String variable, evenStr and oddStr and initialize them with empty string (Line 5-6). These two variables will be used to hold the string at even index and odd index, respectively.

Next, we create a for loop that traverse the characters of the input string from the back by setting initial position index i to  testString.length() - 1  (Line 8). Within the for-loop, create if and else block to check if the current index, i is divisible by 2, (i % 2 == 0), use the current i to get the character of the testString and join it with evenStr. Otherwise, join it with oddStr (Line 10 -14).

At last, we print the concatenated evenStr and oddStr (Line 18).  

You might be interested in
A cannon fires a ball vertically upward from the Earth’s surface. Which one of the following statements concerning the net force
trasher [3.6K]

Answer:

a) The net force on the ball is instantaneously equal to zero newtons at the top of the flight path.

Explanation:

At an instantenous time at the top of the flight path, the upward force due to the Canon explosion on the ball is just equal to the weight of the ball, this will equate the net force on the ball to zero. At this point the velocity of the ball is zero before it decends down to earth under its own weight.

8 0
3 years ago
A vacuum pump is used to drain a basement of 20 °C water (with a density of 998 kg/m3 ). The vapor pressure of water at this tem
lord [1]

Answer:

The maximum theoretical height that the pump can be placed above liquid level is \Delta h=9.975\,m

Explanation:

To pump the water, we need to avoid cavitation. Cavitation is a phenomenon in which liquid experiences a phase transition into the vapour phase because pressure drops below the liquid's vapour pressure at that temperature.  As a liquid is pumped upwards, it's pressure drops. to see why, let's look at Bernoulli's equation:

\frac{\Delta P}{\rho}+g\, \Delta h +\frac{1}{2}  \Delta v^2 =0

(\rho stands here for density, h for height)

Now, we are assuming that there aren't friction losses here. If we assume further that the fluid is pumped out at a very small rate, the velocity term would be negligible, and we get:

\frac{\Delta P}{\rho}+g\, \Delta h  =0

\Delta P= -g\, \rho\, \Delta h

This means that pressure drop is proportional to the suction lift's height.

We want the pressure drop to be small enough for the fluid's pressure to be always above vapour pressure, in the extreme the fluid's pressure will be almost equal to vapour pressure.

That means:

\Delta P = 2.34\,kPa- 100 \,kPa = -97.66 \, kPa\\

We insert that into our last equation and get:

\frac{ \Delta P}{ -g\, \rho\,}= \Delta h\\\Delta h=\frac{97.66 \, kPa}{998 kg/m^3 \, \, 9.81 m/s^2} \\\Delta h=9.975\,m

And that is the absolute highest height that the pump could bear. This, assuming that there isn't friction on the suction pipe's walls, in reality the height might be much less, depending on the system's pipes and pump.

8 0
3 years ago
Incremental software development could be very effectively used for customers who do not have a clear idea about the systems nee
avanturin [10]

<u>Software Development and Client Needs</u>

In Incremental method of software development customers who do not have a basic idea of the development process are being carried along on like other methods that will relegate them to the background until a product is ready.

With this model and structure in place, when softwares/ products are built from several stages e.g prototype, testing, and when new features are added customers are always carried along with their valuable feedback and suggested greatly considered to achieve the customers satisfactions

This model will work well for the customers/clients who does not have a clear idea on the systems needed for their operations.

In summary the incremental model combines features from the waterfall and prototyping model.

For more information on soft ware development process kindly visit

brainly.com/question/20369682

5 0
2 years ago
Which of the following allows team members to visualize a design model from a variety of perspectives?
julsineya [31]

Answer: from what i know im pretty sure its isometrics or sketches im certain its sketches but not 100%

Explanation: A sketch is a rapidly executed freehand drawing that is not usually intended as a finished work. A sketch may serve a number of purposes: it might record something that the artist sees, it might record

8 0
3 years ago
Read 2 more answers
Indicate the correct statement about the effect of Reynolds number on the character of the flow over an object.
sergeinik [125]

Answer:

If Reynolds number increases the extent of the region around the object that is affected by viscosity decreases.

Explanation:

Reynolds number is an important dimensionless parameter in fluid mechanics.

It is calculated as;

R_e__N} = \frac{\rho vd}{\mu}

where;

ρ is density

v is velocity

d is diameter

μ is viscosity

All these parameters are important in calculating Reynolds number and understanding of fluid flow over an object.

In aerodynamics, the higher the Reynolds number, the lesser the viscosity plays a role in the flow around the airfoil. As Reynolds number increases, the boundary layer gets thinner, which results in a lower drag. Or simply put, if Reynolds number increases the extent of the region around the object that is affected by viscosity decreases.

5 0
3 years ago
Other questions:
  • A receptacle, plug, or any other electrical device whose design limits the ability of an electrician to come in contact with any
    14·1 answer
  • Two technicians are discussing solder wire repair. Technician A says that electrical tape can be used to cover the joint. Techni
    10·1 answer
  • Suppose that the time (in hours) required to repair a machine is an exponentially distributed random variable with parameter ???
    13·1 answer
  • The goal of the following model is generate a clock waveform that has the clock high 4 time units and low 4 time units, with the
    15·1 answer
  • What is the angular velocity (in rad/s) of a body rotating at N r.p.m.?
    13·1 answer
  • A strong base (caustic or alkali) is added to oils to test for: b. entrained air a)- alkalinity b)- acidity c)- contamination. d
    11·1 answer
  • The Accenture team is involved in helping a client in the transformation journey using Cloud computing. How is myNav beneficial
    6·1 answer
  • On calculating which of the following quantities , does the body have an effect in simple projectile motion?​
    10·1 answer
  • The Environmental Protection Agency (EPA) has standards and regulations that says that the lead level in soil cannot exceed the
    13·1 answer
  • Can you help me with this task/homework.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!