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
Find the current Lx in the figure
AleksandrR [38]

Explanation:

\frac{1}{8}  +  \frac{1}{2}   \\ 1.6 + 1.4 = 3 \\  \frac{1}{3}  +  \frac{1}{9}   \\ 2.25 + 2 = 4.25 \: ohm

R total = 4.25 ohm

I total = Vt/Rt

I total= 17/4.25= 4 A

Ix= 600 mA

\frac{9}{9 + 3}  \times 4 = 3\\   \frac{2}{2 + 8} \times 3 = 0.6a \\  = 0.6 \: milli \: amper

6 0
3 years ago
5. One of the major road blocks for direct DC power in residences is the ___. A) generation of DC B) lack of standardization C)
Montano1993 [528]

Answer:

D) quantity of components required for this type of system

Explanation:

Electricity can be transmitted using the alternating and direct currents. The alternating current is one in which the flow of the current diverts at certain time intervals whereas, the direct current is one in which there is a constant one-directional flow of current. The DC is used in batteries and solar panels. Residential areas and business places make use of the AC current.

One of the several reasons why the DC is not used in homes is because unlike the AC it is not easy to build and sustain. Moreso, it has more components compared to the AC. For example, its motor consists of brushes and commutators . The components, example, switches are also large compared to the AC components.

6 0
3 years ago
Consider the string length equal to 7. This string is distorted by a function f (x) = 2 sin(2x) - 10sin(10x). What is the wave f
fenix001 [56]

Answer:

hello your question has a missing part below is the missing part

Consider the string length equal to \pi

answer : 2cos(2t) sin(2x) - 10cos(10t)sin(10x)

Explanation:

Given string length = \pi

distorted function f(x) = 2sin(2x) - 10sin(10x)

Determine the wave formed in the string

attached below is a detailed solution of the problem

8 0
3 years ago
Is 4/16 equal in measurement to 1/4
Alja [10]

Answer:yes

Explanation:

5 0
3 years ago
Read 2 more answers
Type the correct answer in the box. Spell all words correctly.
Alik [6]

Answer:

management engineer

Explanation:

A Management Engineer is someone with a commercial engineering understanding and marketing techniques.

The role of a management engineer covers overseeing the activities of all the engineering departments in an engineering firm particularly in the area of product development, implementation, and production.

This is to ensure the products meet and satisfy the business methods and techniques specifically in the area of cost efficiency and quality product.

Under Management Engineering there are subdivisions of Manufacturing and Industrial Engineer, which both fit the role of Malcolm.

Hence, in this case, Malcolm work as a Management Engineer

8 0
3 years ago
Other questions:
  • List irreversibilities
    11·1 answer
  • Give an example of one technology that is well matched to the needs of the environment, and one technology that is not.
    9·1 answer
  • Water is flowing in a metal pipe. The pipe OD (outside diameter) is 61 cm. The pipe length is 120 m. The pipe wall thickness is
    9·1 answer
  • Which of these is the coarsest grit abrasive that may be used on aluminum?
    15·2 answers
  • A subsurface exploration report shows that the average water content of a fine-grained soil in a proposed borrow area is 22% and
    9·1 answer
  • A homeowner consumes 260 kWh of energy in July when the family is on vacation most of the time. Determine the average cost per k
    7·1 answer
  • Ohm's law states that the current (I) in amps equals the voltage (E) in volts decided by the resistance (R) in ohm's. If you con
    15·1 answer
  • Cody’s car accelerates from 0m/s to 45 m/s northward in 15 seconds. What is the acceleration of the car
    14·1 answer
  • As you get older your muscles grow. True or False
    15·2 answers
  • (i) what assumptions about the relationship between the inputs and output are inherent in this specification? do scatter plots s
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!