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
Alex73 [517]
2 years ago
8

Write method reverseString, which takes a string str and returns a new string with the characters in str in reverse order. For e

xample, reverseString("ABCDE") should return "EDCBA".
Complete the reverseString method below by assigning the reversed string to result.

/** Takes a string str and returns a new string

* with the characters reversed.

*/

public static String reverseString(String str)

{

String result = "";

return result;

}
Computers and Technology
1 answer:
son4ous [18]2 years ago
3 0

Answer:

The method written in Java is as follows:

public static String reverseString(String str){

    String result = "";

    int lentt = str.length();

    char[] strArray = str.toCharArray();

       for (int i = lentt - 1; i >= 0; i--)

           result+=strArray[i];

    return result;

}

Explanation:

This defines the method

public static String reverseString(String str){

This initializes the result of the reversed string to an empty string

    String result = "";

This calculates the length of the string

    int lentt = str.length();

This converts the string to a char array

    char[] strArray = str.toCharArray();

This iterates through the char array

       for (int i = lentt - 1; i >= 0; i--)

This gets the reversed string

           result+=strArray[i];

This returns the reversed string            

    return result;

}

<em>See attachment for full program that includes the main method</em>

Download txt
You might be interested in
Understanding Sequential Statements Summary
Kisachek [45]

Answer:

// Payroll.java

public class Payroll

{

int numOfDependents;

double salary;

double salaryToHome;

double Federal_Tax,TAX_RATE,Depen_tax;

 

Payroll(double salry,int nod)

{

numOfDependents=nod;

salary=salry;

Federal_Tax=6.5;

TAX_RATE=28.0;

Depen_tax=2.5;

}

 

double getTAX_RATE()

{

return TAX_RATE*salary/100;

}

double Federal_Tax()

{

return Federal_Tax*salary/100;

}

double getDepenAmount()

{

return numOfDependents*(Depen_tax*salary/100);

}

double getTakeHomeSalary()

{

return salary+getDepenAmount()-(getTAX_RATE()+Federal_Tax());

}

void printOutput()

{

System.out.print("\nState Tax: $"+getTAX_RATE());

System.out.print("\nFederal Tax: $"+Federal_Tax());

System.out.print("\nDependents: $"+getDepenAmount());

System.out.print("\nSalary: $"+salary);

System.out.println("\nTake Home Pay: $"+getTakeHomeSalary());

 

}

public static void main(String args[])

{

Payroll obj=new Payroll(1250,2);

obj.printOutput();

}

}

// ModifiedPayroll.java

import java.util.Scanner;

public class ModifiedPayroll

{

 

int numOfDependents;

double salary;

double salaryToHome;

double Federal_Tax,TAX_RATE,Depen_tax;

 

ModifiedPayroll(double salry,int nod)

{

//initialise variables

numOfDependents=nod;

salary=salry;

Federal_Tax=6.5;

TAX_RATE=28.0;

Depen_tax=2.5;

}

 

double getTAX_RATE()

{

return TAX_RATE*salary/100;

}

double Federal_Tax()

{

return Federal_Tax*salary/100;

}

double getDepenAmount()

{

return numOfDependents*(Depen_tax*salary/100);

}

double getTakeHomeSalary()

{

return salary+getDepenAmount()-(getTAX_RATE()+Federal_Tax());

}

void printOutput()

{

System.out.print("\nState Tax: $"+getTAX_RATE());

System.out.print("\nFederal Tax: $"+Federal_Tax());

System.out.print("\nDependents: $"+getDepenAmount());

System.out.print("\nSalary: $"+salary);

System.out.println("\nTake Home Pay: $"+getTakeHomeSalary());

 

}

public static void main(String args[])

{

Scanner sc=new Scanner(System.in);

System.out.print("\nEnter Salary: $");

double salary=sc.nextDouble();

System.out.print("\nEnter number Of Dependents:$");

int nob=sc.nextInt();

ModifiedPayroll obj=new ModifiedPayroll(salary,nob);

obj.printOutput();

}

}

Explanation/Output:

// For Payroll.java

State Tax: $350.0

Federal Tax: $81.25

Dependents: $62.5

Salary: $1250.0

Take Home Pay: $881.25

// For ModifiedPayroll.java

Enter Salary:$1550.0

Enter number of Dependents:$3

State Tax: $434.0

Federal Tax: $100.75

Dependents: $116.25

Salary: $1550.0

Take Home Pay: $1131.5

8 0
3 years ago
Question 4. Use simulate_several_key_strikes 1000 times, each time simulating the monkey striking 11 keys. Compute the proportio
Arisa [49]

Answer:

Chech the explanation

Explanation:

<em>In [16]:</em>

<em />

# Your answer to this question might be written on more than a line.

datascience_trials = make_array()

for  i  in np.arange(1000):

            datascience_trials = np.append(datascience_trials, simulate_several_key_strikes(1))

datascience_proportion = np.count_nonzero(datascience_trials == 'datascience')/1000

datascience_proportion

<em>Out [16]:</em>

0.0

<em>In [17]:</em>

_ = ok.grade('q2_4')

````````````````````````````````````````````````````````````````````````````````````````````````````````

#Running tests

4 0
3 years ago
Phone cords are a type of twisted-pair cable and use an rj-45 connector.
Nezavi [6.7K]
The answer is FALSE

The RJ11 is most commonly known as the "telephone" standard. Most wired landline phones almost certainly use an RJ11 jack or an RJ11 connector. RJ11 has between 4 or 6 wire connection, but only 2 wires are used for connection as compared to a RJ14 which is also used in connecting telephone lines and uses 4 wires for connection.
3 0
3 years ago
Let's get into some looping. Sometimes it is nice to generate your own data. Now let's take our first stab at it.
valkas [14]

Answer:

55

Explanation:

3 0
3 years ago
When working with a large worksheet, you can split the window into ____ panes.?
krek1111 [17]
When working with a large worksheet, you can split the window into two or four panes.
5 0
3 years ago
Other questions:
  • Write the function "zipper". the function will take two array/list/table parameters and return a new array/list/table which will
    15·1 answer
  • Explain how to implement two stacks in one array A[1..n] in such a way that neither stack overflows unless the total number elem
    7·1 answer
  • Which trait depicts honesty?
    10·1 answer
  • A new product was introduced in 2003, which functions as both an identification device and a medium of communication. It uses in
    8·1 answer
  • The domain name service (dns is a distributed database that allows users to communicate with each other computers by:
    7·1 answer
  • In a distributed database system, the data placement alternative with the highest reliability and availability is Group of answe
    9·1 answer
  • Who invented the speaker?
    14·2 answers
  • How do I get the bot token for discord? (scripting etc)
    5·1 answer
  • What is HTML? Write some future of HTML.<br>follow for follow ​
    15·2 answers
  • Software that communicates with the hardware and allows other programs to run. It is comprised of system software, or the fundam
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!