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
Ierofanga [76]
3 years ago
5

Write a Java program that generates a new string by concatenating the reversed substrings of even indexes and odd indexes separa

tely from a given string.

Computers and Technology
1 answer:
salantis [7]3 years ago
8 0

Answer:

/ReversedEvenOddString.java

import java.util.Scanner;

public class ReversedEvenOddString {

   public static void main(String[] args) {

       Scanner sc = new Scanner(System.in);

       String s = sc.nextLine();

       String evens = "";

       String odds = "";

       for(int i = s.length()-1;i>=0;i--){

           if(i%2==1){

               odds += s.charAt(i);

           }

           else{

               evens += s.charAt(i);

           }

       }

       String res;

       if(s.length()%2==1){

           res = evens+odds;

       }

       else{

           res = odds+evens;

       }

       System.out.println(res);

   }

}

You might be interested in
Given: an int variable k, an int array current Members that has been declared and initialized, an int variable memberID that has
Alekssandra [29.7K]

Answer:

The c++ program is given below. Nothing is displayed as per the question.

#include <iostream>

using namespace std;

int main() {    

   // declaration and initialization of integer variables

   int k, memberID = 12, nMembers=5;

   bool isAMember;    

   // declaration and initialization of integer array

   int currentMembers[] = {12, 34, 56, 78, 90};    

   for(k=0; k<nMembers; k++)

   {

       if(memberID == currentMembers[k])

       {

           // when member is found in the array, the loop is exited using break

           isAMember = true;

           break;

       }

       else

           isAMember = false;

   }    

   return 0;

}

Explanation:

The program begins with declaration and initialization of integer variables and followed by initialization of the array holding the id of all the members.

The Boolean variable is declared but not initialized.

int k, memberID = 12, nMembers=5;

bool isAMember;

int currentMembers[] = {12, 34, 56, 78, 90};

After this, the array holding the id of the members is searched for the given member id. This is done using  a for loop and a if else statement inside the loop.

If the member id is present in the array, the variable isAMember is initialized to true otherwise it is assigned false.

When the variable isAMember is initialized to true, the break statement is used to exit from the loop.

for(k=0; k<nMembers; k++)

   {

       if(memberID == currentMembers[k])

       {

           isAMember = true;

           break;

       }

       else

           isAMember = false;

 }

The break is used since other values of id in the array will not match the given member id and the variable, isAMember will be initialized to false even if the given member id is present in the array. Hence, it is mandatory to exit the loop once the given member id is found in the array.

This program can be tested for different values of the id of the members and different sizes of the array.

4 0
3 years ago
As Jason walks down the street, a large raven starts squawking at him and flapping its wings. Jason thinks to himself ‘That bird
UNO [17]

Answer:

Answer to the following question is anthropomorphism.

Explanation:

Anthropomorphism is considered as the error in the following context of the scientific reductionism. Anthropomorphize is the source of an error that needs to reconsider.

Anthropomorphism is an attribute of the human qualities, emotions, thoughts, motivation, intentions, and characteristics to the non-living beings or the nonhuman beings, things or objects.

8 0
3 years ago
A user reports that a PC gets a BSOD on startup. A technician has researched the error message and found a driver to replace. Wh
7nadin3 [17]

Answer:

The explanation of this question is given below in the explanation section. however, the correct option of this question is "Boot the machine into safe mode"

Explanation:

BSOD error on startup

Blue screen of death error arises mostly when dirver produce fault into system or did not install properly. however, the correct option for this question, if PC gets BSOD error on startup then it is the best option for technician to remove the hardware that is recently installed and/or try to boot the machine into safe mode, then uninstall the driver that causing error on startup.

BSOD error occur during running the program on PC

However, if PC get BSOD during running program, then the best option for technician is to restart the machine and then install the driver properly. During this operation, as error occured, you may loss the data becuase you have no other option to save the data of program that is running.

6 0
3 years ago
Int [] val = { 3, 10, 44 };
irina1246 [14]

Answer:

5) 3 0 0

Explanation:

Given data

int [] val = { 3, 10, 44 };

The total number of parameters of given array are 3, so total length of array is also 3.

The indexing of array starts with '0', Therefore the indexes of array with length zero are: {0,1,2}

The value of array at index 0 is = 3

similarly

value at index 1 = 10

value at index 2 = 44

Here, Int i = 1 is storing the value '1' in integer variable i.

In addition to that, any value of index 'i' of an array is selected using array[i].

Therefore,

val[i] = i-1 is copying the value (i-1 = 1-1 = 0) to the index '1'  of the array because i = 1.

So value at index 1 would be = val[1] = 0

The term i++ is incrementing the value of i, it makes i =2

val[i] = i-1 is copying the value (i-1 = 1-1 = 0) to the index '2' of the array because i = 2 now.

So value at index 2 would be = val[2] = 0

Hence, the output would be {3 0 0}. So 5th option is correct.

4 0
2 years ago
Which wireless communication is typically limited to six feet of distance?
Anni [7]

Answer:

nfc

Explanation:

8 0
3 years ago
Other questions:
  • Talking to a friend _____.
    5·2 answers
  • Which of the following is an object-oriented prototype-based language? Java Pike REBOL MATLAB
    9·1 answer
  • You can't get close enough to the facility interior to launch an evil twin attack against its wireless clients; in fact, you hav
    11·1 answer
  • Write a function named "isValidPassword" that takes in a string and returns 1 if it stores a valid password and 0 otherwise, A v
    12·1 answer
  • State any three points of importance of local level profession​
    11·1 answer
  • What is the IP address and TCP port number used by the client computer (source) that is transferring the file to gaia.cs.umass.e
    9·1 answer
  • Can geico save me 15% or more on car insurance?
    8·2 answers
  • How do you think weather can affect sailing?<br><br>What would be good sailing weather?​
    9·1 answer
  • 5. Why do we need programming language?​
    13·2 answers
  • Custodial workers that access the terminal area must have a fingerprint background check done and training unless they are escor
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!