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) Design a lag compensation to meet the following specifications: The step response settling time is to be less than 5 sec, th
Pavlova-9 [17]

Answer:

Please see the attached file for the complete answer.

Explanation:

Download pdf
4 0
3 years ago
Which factor is typically not a requisite feature of setting a career goal?
Vaselesa [24]

Answer:

Explanation: Analysing the goal of the family is not a requisite feature of setting a career goal. It is an individual person's ability and topic of interest so the family goal cannot be taken into consideration. Brainliest

Explanation:

5 0
3 years ago
A fluid flows through a 10-mm diameter tube at a Reynolds number of 1800. If the flow rate is 6.0 liters/min, what is the head l
Eddi Din [679]

Answer:

29.31 m

Explanation:

It is given that flow rate Q =6.0 ltrs/minute =\frac{6}{1000\times 60} m^3/sec

Diameter =10 mm

So radius =  \frac{10}{2}=5 mm=5\times 10^{-3}m

Area of duct A=\pi r^2=3.14\times(5\times 10^{-3})^2=7.854 \times 10^{-5}m^2

Average velocity v=\frac{Q}{A}=\frac{10^{-4}}{7.854\times 10^{-5}}=1.372 m/sec

The given Reynolds number is 1800 which is less than 2000 so it will be a laminar flow

So Reynolds number friction factor f=\frac{64}{1800}=0.0356

So head loss ifs given by \frac{fLv_{avg}^2}{d\times 2\times g}=\frac{0.0356\times 100\times 1.732^2}{10\times 10^{-3}\times 2\times 9.81}=29.39\ m

5 0
3 years ago
A source which can be represented by a 12 V rms voltage source in series with a resistance of 1.5 k is connected to a 75- load r
Margarita [4]

Answer:

Number of turns ratio is 0.22 and power is 98mw.

Explanation:

Please look at the attached solutions.

4 0
4 years ago
Tech distractions do NOT include _________.
likoan [24]
D, setting phone BEFORE
7 0
4 years ago
Other questions:
  • A hot-water stream at 80°C enters a mixing chamber with a mass flow rate of 0.56 kg/s where it is mixed with a stream of cold wa
    7·1 answer
  • A turbine operates at steady state, and experiences a heat loss. 1.1 kg/s of water flows through the system. The inlet is mainta
    6·1 answer
  • an aluminum bar 125mm (5in) long and having a square cross section 16.5mm (.65in) on an edge is pulled in tension with a load of
    6·1 answer
  • Describe the operation of a pneumatic robot controlled by a drum
    10·1 answer
  • What does the branch of physics include
    13·1 answer
  • If the middle bend of a three-bend saddle is a 30-degree bend
    6·2 answers
  • Comparing cold working to hot working, flow stress is usually lower in _____ Question 19 options: Cold working Hot working
    10·1 answer
  • If you are running and you fall and everyone↓↓↓↓↓↓↓ passes you how can you still be in first place??
    12·1 answer
  • How does your physical location impact the design of your product?
    15·1 answer
  • Which symbol warns that there is something wrong with your alternator?
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!