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
Energy.
alexandr402 [8]

Answer:

modern vehicles are made to crunch up a little bit so they that absorbe some of the impact instead of you

Explanation:

8 0
3 years ago
A small metal particle passes downward through a fluid medium while being subjected to the attraction of a magnetic field such t
bekas [8.4K]

Answer:

a)Δs = 834 mm

b)V=1122 mm/s

a=450\ mm/s^2

Explanation:

Given that

s = 15t^3 - 3t\ mm

a)

When t= 2 s

s = 15t^3 - 3t\ mm

s = 15\times 2^3 - 3\times 2\ mm

s= 114 mm

At t= 4 s

s = 15t^3 - 3t\ mm

s = 15\times 4^3- 3\times 4\ mm

s= 948 mm

So the displacement between 2 s to 4 s

Δs = 948 - 114 mm

Δs = 834 mm

b)

We know that velocity V

V=\dfrac{ds}{dt}

\dfrac{ds}{dt}=45t^2-3

At t=  5 s

V=45t^2-3

V=45\times 5^2-3

V=1122 mm/s

We know that acceleration a

a=\dfrac{d^2s}{dt^2}

\dfrac{d^2s}{dt^2}=90t

a= 90 t

a = 90 x 5

a=450\ mm/s^2

4 0
3 years ago
Decide whether the function is an exponential growth or exponential decay function, and find the constant percentage rate of gro
sasho [114]

Answer:

Just answered this to confirm my profile.

Explanation:

I dont have a clue, this is just to confirm my profile.

8 0
3 years ago
You work in a furniture store. You receive a
spin [16.1K]

Answer:

18 pieces of furniture

Explanation:

Since you receive $120.93 per furniture piece and a the month's commission is $2,176.74 you divide the commission by the furniture price.

  • 2176.74/120.93
3 0
3 years ago
Read 2 more answers
What does the air change rate represent?
Juli2301 [7.4K]

Answer and Explanation:

  • The removal or addition of air volume to the space is the air change rate
  • The rate of air change is positive when air volume is added to the space and the rate of air change is negative when air volume is removed from the space.
  • The standard built home has a 0.5 to 1 of air change rate.
  • The rate of air change is dependent on the building (how the building form)  

3 0
3 years ago
Other questions:
  • A civil engineer is studying a left-turn lane that is long enough to hold seven cars. Let X be the number of cars in the line at
    11·2 answers
  • (Practice work, not graded)
    11·1 answer
  • A common rule of thumb for controller discretization is to have "6 samples per rise time" in order to achieve a reasonable appro
    9·1 answer
  • A square power screw has a mean diameter of 30 mm and a pitch of 4 mm with single thread. The collar diameter can be assumed to
    14·1 answer
  • Define ways in which you would go about networking to explore opportunities in your career field and obtain more information for
    11·1 answer
  • The purpose of pasteurizing milk is to
    13·2 answers
  • At the coast on a summer day, the land is hotter than the ocean. Warm air over the land rises and is replaced by cooler air, cau
    14·2 answers
  • What is the least count of screw gauge?<br> (a) 0.01 cm<br> (b) 0.001 cm<br> (c) 0.1 cm<br> (d) 1 mm
    13·1 answer
  • Who here likes to play project gotham racing?<br> will mark brainlyest
    8·2 answers
  • if both the ram air input and drain hole of the pitot system become blocked, the indicated airspeed will
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!