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
mestny [16]
3 years ago
10

Write a method that accepts a String object as an argument and displays its contents backward. For instance, if the string argum

ent is "gravity" the method should display "ytivarg". Demonstrate the method in a program that asks the user to input a string and then prints out the result of passing the string into the method.
Computers and Technology
1 answer:
Nata [24]3 years ago
6 0

Answer:

// importing the necessary libraries

import java.util.Scanner;

public class BackwardString {

public static void main(String[] args) {

String input;

// Scanner object to read string from user input

Scanner scanner = new Scanner(System.in);

System.out.print("Enter String here : ");

input=scanner.next();

// calling backward method to reverse passed string

backward(input);

// closing Scanner object

scanner.close();

}

// Method to Reverse the input string

private static void backward(String source) {

int i, len = source.length();

StringBuilder dest = new StringBuilder(len);

for (i = (len - 1); i >= 0; i--){

dest.append(source.charAt(i));

}

System.out.println("Reversed String : "+dest);

}

}

Explanation:

// importing the necessary libraries

import java.util.Scanner;

public class BackwardString {

public static void main(String[] args) {

String input;

// Scanner object to read string from user input

Scanner scanner = new Scanner(System.in);

System.out.print("Enter String here : ");

input=scanner.next();

// calling backward method to reverse passed string

backward(input);

// closing Scanner object

scanner.close();

}

// Method to Reverse the input string

private static void backward(String source) {

int i, len = source.length();

StringBuilder dest = new StringBuilder(len);

for (i = (len - 1); i >= 0; i--){

dest.append(source.charAt(i));

}

System.out.println("Reversed String : "+dest);

}

}

The program above accepts a String object as an argument and displays its contents backward.

It reverses the any string inputed while producing the output.

You might be interested in
Hi this is for computer and technology experts out there but can someone tell me why my dell computer charger wont work please h
exis [7]
It probably short circuited or something inside your computer hole is broken
7 0
3 years ago
Read 2 more answers
Shift Registers. What is a Bit Shift Register? What are the different types of Bit Shift Registers and what might be their appli
lesya [120]

Answer:

Digital logic circuits made of cascaded flip flops.

The different types of Bit Shift Registers are; Serial-In Serial-Out, Parallel-In Parallel-Out, Serial-In Parallel-Out, Parallel-In Serial-Out.

Shift registers can be used as converters to translate data, as delay circuits or counters.

Explanation:

Shift Registers are digital logic circuits made of cascaded flip flops. Their main function is to shift their contents (bits) to the right or to the left one bit at a time. Bit Shift Registers can process data either parallelly or serially. So the different types of Bit Shift Registers are;

  • Serial-In Serial-Out
  • Parallel-In Parallel-Out
  • Serial-In Parallel-Out
  • Parallel-In Serial-Out

Because of their ability to convert data from parallel to serial, shift registers can be used as converters to translate data. Some of their other applications are also delay circuits or counters, storing and manipulating data etc.

I hope this answer helps.

8 0
3 years ago
Assume the variable sales references a float value. Write a statement that displays the value rounded to two decimal points.Assu
romanna [79]

Answer:

The statement is as follows:

print("{0:,.1f}".format(number))

Explanation:

Required

Statement to print 1234567.456 as 1,234,567.5

To do this, we make use of the format keyword, and we set the print format in the process.

To round up number to 1 decimal place, we use the following format:

"{0:,.1f}"

To include comma in the thousand place, we simply include a comma sign before the number of decimal place of the output; i.e. before 1

"{0:,.1f}"

So, the print statement is:

print("{0:,.1f}".format(number))

3 0
3 years ago
ap csp The local, remote, and upstream _______ can each have multiple ___ _____. When a participant in a collaborative group on
ratelena [41]

Answer:

The Local, Remote and Upstream repository can each have multiple push /pull requests. When  a Participant in a collaborative group on Github is ready to have their work used by the group,  the participants makes a pull request.

Explanation:

These are simple blanks which are answer here

The Local, Remote and Upstream <u>repository</u> can each have multiple <u>push /pull</u> requests. When  a Participant in a collaborative group on Github is ready to have their work used by the group,  the participants makes a <u>pull request</u>.

8 0
3 years ago
The procurement department of an organization helps to program software. <br> A)True<br> B)False
valina [46]
I think it is true absolutely
8 0
3 years ago
Read 2 more answers
Other questions:
  • Input numbers and segregate them by placing their values into even or odd vectors based upon their value being even or odd. Then
    12·1 answer
  • The process of analyzing data to extract information not offered by the raw data alone; it uncovers trends and patterns using te
    6·1 answer
  • Keyshia is preparing a report about the different tools that are used in a science laboratory. She wants to edit a picture of gl
    11·2 answers
  • Hurry asap it’s times
    8·1 answer
  • You can run a macro by:
    10·1 answer
  • Which software development team memeber is responsible for the timeline and budget
    9·1 answer
  • tls Explain in your own words how, by applying both asymmetric and symmetric encryption, your browser uses TLS to protect the pr
    8·1 answer
  • Function of an actuator
    8·2 answers
  • Water is constantly in motion.<br> True or false
    6·1 answer
  • This is a while loop question for Information technology.
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!