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
Tech a says you should push the wrench when braking a fastener loose. Tech b says that you should pull the wrench when braking a
Kay [80]

Answer:

tech b because gut feeling

Explanation:

4 0
3 years ago
A friend would like you to build an "electronic eye" for use as a fake security device. The device consists of three lights line
mars1129 [50]

Answer and explanation:

The graphical representation of the electronic eye

The state table showing

the present state

input

Next state and

the output

are shown in the attached file

8 0
3 years ago
Read 2 more answers
What is the connection between the air fuel ratio and an engine running rich/poor? please give clear examples and full sentances
gavmur [86]

Explanation:

Air fuel ratio:

 Air fuel ratio is the ratio of mass of air to the mass of fuel.So we can say that

Air\ fuel\ ratio=\dfrac{mass\ of\ air}{mass\ of\ fuel}

As we know that fuel burn in the presence of air that is why we have to maintain a proper amount of air fuel ratio.

When we need more power then we have supply more fuel and to burn this fuel ,require a specified amount of air.So for different loading condition of engine different air fuel ratio is required.

When air is less and fuel is more then it is called rich air fuel ratio .when air is more and fuel is less then it is called poor air fuel ratio.

5 0
3 years ago
The Clausius inequality expresses which of the following laws? i. Law of Conservation of Mass ii. Law of Conservation of Energy
DanielleElmas [232]

Answer:

(iv) second law of thermodynamics

Explanation:

The Clausius  inequality expresses the second law of thermodynamics it applies to the real engine cycle.It is defined as the cycle integral of change in entropy of a reversible system is zero. It is nothing but mathematical form of second law of thermodynamics . It also states that for irreversible process the cyclic integral of change in entropy is less than zero

3 0
3 years ago
______ are an idication that your vehicle may be developing a cooling system problem.
iris [78.8K]

Answer:

The temperature gauge showing that the vehicle has been running warmer or has recently began to have issues from overheating is  an idication that your vehicle may be developing a cooling system problem.

Explanation:

8 0
3 years ago
Other questions:
  • In C++ the declaration of floating point variables starts with the type name float or double, followed by the name of the variab
    14·1 answer
  • Which term defines the amount of mechanical work an engine can do per unit of heat energy it uses?
    5·1 answer
  • Alberto's mom is taking a splinter out of his hand with a pair of tweezers. The tweezers are 3 inches long. She is applying .25
    12·2 answers
  • Assuming that the following three variables have already been declared, which variable will store a Boolean value after these st
    14·1 answer
  • Power is a fundamental dimension. a) True b) False
    15·1 answer
  • Write a function named "total_population" that takes a string then a list as parameters where the string represents the name of
    5·1 answer
  • Estimate the uncertainty in a 22 m/sec air velocity measurement using a Pitot tube at 20C. Assume the atmospheric pressure is 1
    7·1 answer
  • Implement a quick sort algorithm that will accept an integer array of size n and in random order. Develop or research three diff
    13·1 answer
  • Ferroconcrete is reinforced concrete that combines concrete and ________. A. Lead c. Copper b. Iron d. Aluminum.
    6·1 answer
  • A ruptured desiccant bag in a reciever-driver is usually caused by what?​
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!