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]
2 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]2 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
7. What is the voltage across a 100 ohm circuit element that draws a current of 1 A?
Marianna [84]

Answer:

100 V

Explanation:

V = IR

100 x 1 = 100

100 volts

3 0
3 years ago
Suppose you are asked to design an office building. Explain what type of drawing you would use and why.
ohaa [14]

Answer:

birds-eye view perspective

Explanation:

If someone asked me to design an office building, I would draw it from a birds-eye view perspective. I would draw it this way so I could map out where everything in the office would go and make sure I have enough space for everything. I would also draw it this way in order to clearly see where everything would go in the office. For instance, cubicles/desks could go in the bottom left corner, while the boss's office could go in the top right. It would be easier to organize and it would be easier for me to look back on when I need to actually design the office later.

(i'm not sure if this is what your question is asking for so i just made my best guess)

7 0
3 years ago
Read 2 more answers
(Signal Property) Under what condition is a discrete-time signal x[????] or a continuous-time signal x(????) periodic? Determine
Cloud [144]

Answer:

a. 2x/3

b. 8

Explanation:

fundamental period can be defined to mean that at after every period of 2π radians or 360° the value of graph is repeated. For such functions the fundamental period is the period after which they repeat themselves.

It van also be looked as The fundamental period of cos(θ) is 2π. That is (for example) cos(0) to cos(2π) represents one full period.

Please see attachment for the step by step solution.

7 0
3 years ago
A ball thrown vertically upward from the top of a building of 60ft with an initial velocity of vA=35 ft/s. Determine (a) how hig
Masteriza [31]

Answer:

A.) 62.5 ft

B.) 3.58 seconds

C.) 8.58 seconds

Explanation:

A.) Given that a ball is thrown vertically upward from the top of a building of 60ft with an initial velocity of vA=35 ft/s

To determine how high above the top of the building the ball will go before it stops at B, let us use the third equation of motion.

V^2 = U^2 - 2gH

Since the ball is going up, g will be negative. And at maximum height, V = 0

Substitute all the parameters into the formula

0 = 35^2 - 2 × 9.8 × H

19.6H = 1225

H = 1225/19.6

H = 62.5 ft

(B) The time tAB it takes to reach its maximum height will be achieved by using second equation of motion

H = Ut - 1/2gt^2

Substitutes all the parameters into the formula

62.5 = 35t - 1/2 × 9.8 × t^2

62.5 = 35t - 4.9t^2

4.9t^2 - 35t + 62.5 = 0

Let's use quadratic equations to find t

Divide all by 4.9

t^2 - 7.143t + 12.755 = 0

t^2 - 7.143t + 3.57^2 = - 12.755 + 3.57^2

( t - 3.57)^2 = 0.000102

( t - 3.57 ) = +/-( 0.01 )

t = 3.57 + 0.01

t = 3.58 seconds

Ignore the negative one.

(C) the total time tAC needed for it to reach the ground at C from the instant it is released.

When the object is falling back from B, the initial velocity = 0. And the height h will be 60 + 62.5 = 122.5 ft

Using equation 2 of equations of motion again.

h = 1/2gt^2

122.5 = 1/2 × 9.8 × t^2

122.5 = 4.9t^2

t^2 = 122.5/4.9

t^2 = 25

t = 5

Total time = 5 + 3.58 = 8.58 seconds

3 0
3 years ago
X cotx expansion using maclaurins theorem.
Lemur [1.5K]

It is to be noted that it is impossible to find the Maclaurin Expansion for F(x) = cotx.

<h3>What is Maclaurin Expansion?</h3>

The Maclaurin Expansion is a Taylor series that has been expanded around the reference point zero and has the formula f(x)=f(0)+f′. (0) 1! x+f″ (0) 2! x2+⋯+f[n](0)n!

<h3>What is the explanation for the above?</h3>

as indicated above, the Maclaurin infinite series expansion is given as:

F(x)=f(0)+f′. (0) 1! x+f″ (0) 2! x2+⋯+f[n](0)n!

If F(0) = Cot 0

F(0) = ∝ = 1/0

This is not definitive,

Hence, it is impossible to find the Maclaurin infinite series expansion for F(x) = cotx.

Learn more about Maclaurin Expansion at;
brainly.com/question/7846182
#SPJ1

4 0
1 year ago
Other questions:
  • Joseph wants to practice architecture. Which compulsory assessment administered by NCARB does he need to complete?
    10·1 answer
  • Which one of the following statements about the Wright brothers is not true?
    6·1 answer
  • What is pixel's intensity ?​
    8·1 answer
  • When using levers like scissors or hedge clippers, what can be done to increase the cutting force so that you don’t have to sque
    5·1 answer
  • Heat in the amount of 100 kJ is transferred directly from a hot reservoir at 1200 K to a cold reservoir at 600 K. Calculate the
    15·1 answer
  • Is air conditioner a refrigerator?
    10·1 answer
  • A 0.39 percent Carbon hypoeutectoid plain-carbon steel is slowly cooled from 950 oC to a temperature just slightly below 723 oC.
    15·1 answer
  • An ideal vapor-compression refrigeration cycle using refrigerant-134a as the working fluid is used to cool a brine solution to −
    12·1 answer
  • What is the moment that the wrench puts on the bolt?
    13·1 answer
  • Respond with TRUE if the symbol of the valve shown belows
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!