answer.
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]
1 year 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]1 year 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
Provide an example by creating a short story or explanation of an instance where availability would be broken.
noname [10]

Explanation:

Personal Insurance

Confidentiality in the workplace: What you need to know

When you give advice to clients or patients for a living, you'll know that protecting sensitive and personal information is crucial. But are you clear on what counts as a breach of confidence or what to do if one occurs?

From how to protect confidential information, to what breaches of confidence look like for different jobs, here's what you need to know about confidentiality in the workplace.

What is a breach of confidentiality?

In short, a confidentiality breach is the disclosure of information to someone without the consent of the person who owns it. In other words, failing to respect a person's privacy or the confidence in which they gave the information or data to you, by passing it onto someone else.

Why is confidentiality important?

Protecting confidential information is vital. If you're in a position where you have access to or are given this type of data at work, your career relies on your ability to keep patient or client confidentiality. If you don't, you could lose trust and integrity in the eyes of your existing (and potential future) clients, who could terminate your contract and take legal action against you.

Therapist/patient confidentiality

Unsurprisingly, patient confidentiality is highly important for therapists and counsellors. It forms part of the therapeutic frame of appropriate boundaries, which creates a safe space for a good working relationship to form.

Here’re some examples of ways you could unintentionally break patient/therapist confidentiality:

Sharing confidential information about a client with a family member or friend

Talking about confidential information somewhere you can be overheard

Leaving your computer containing confidential information open to others

Continuing to work with a client when there's a conflict of interests (for example, they know one of your family members or friends)

When permission to share information is given but isn't specific, this can create confusion and result in a potential breach (for example, a patient may give permission for their information to be shared with a teacher but not their GP)

7 0
1 year ago
Which presenter would most likely benefit from a custom slide show?
PIT_PIT [208]
Which presenter would most likely benefit from a custom slide show?

a teacher who teaches four sessions of the same course
3 0
1 year ago
Read 2 more answers
Show how to define a view tot_credits (year, num_credits), giving the total number of credits taken by students in each year
andreev551 [17]

Hi! I'm a Digital Marketer Intern at hotels.ng and I have a moderate knowledge on programming.

First, your  question is not very explanatory. The term "view" is often used in back-end web development. A view is simply a Python function that takes a Web request and returns a Web response.

But I'm not sure this is what you want, so I'll just go ahead and write a python function involving class to return the total number of credits taken by a student.

I'll answer this question using Python.

class student(object):  

    credits = None

    year = None

    def num_credits(self):


       #get credit value

       self.credits = input("Enter the total number of credits: "  )


       pass

    def getYear(self):

        self.year = input("Enter current year: ")

        pass

    def tot_credits(self):

          TotalCredits = tempTotalCredits + self.num_credits

           print "Your  total credits are :"+" "+str(TotalCredits)




3 0
1 year ago
Taylor and Rory are hosting a party. They sent out invitations, and each one collected responses into dictionaries, with names o
disa [49]

Answer:

Following are the code to this question:

def combine_guest(guest1, guest2):#defining a method combine_guest that accepts two dictionary

   guest2.update (guest1)#use dictionary guest2 that use update method to update guest2 dictionary

   return guest2#return guest2 dictionary values

Rory_guest= { "Ada":2, "Ben":3, "Dav":1, "Jo":3, "Charry":2, "Terry":1, "bob":4}#defining a dictionary and add value

Taylor_guest = { "Dav":4, "Nan":1, "bobert":2, "Ada":1, "Samantha":3, "Chr":5}#defining a dictionary and add value

print(combine_guest(Rory_guest,Taylor_guest))#calling the combine_guest method

Output:

{'Nan': 1, 'Samantha': 3, 'Ada': 2, 'bob': 4, 'Terry': 1, 'Jo': 3, 'Ben': 3, 'Dav': 1, 'Charry': 2, 'bobert': 2, 'Chr': 5}

Explanation:

In the code a method, "combine_guest" is defined, that accepts two dictionaries "guest1, guest2" inside the method, in which the "guest2" dictionary uses the update method to combine the value of the guest1 dictionary and use a return keyword to return guest2 values.

In the next step, two dictionaries are declared, that holds some values and use a print method to call the "combine_guest" method and prints its return values.  

7 0
1 year ago
Which command suppresses the visibility of a particular Row or column in a worksheet?
leonid [27]

Answer:

Ctrl+Space is the keyboard shortcut to select an entire column.

Explanation:

When you press the Shift+Space shortcut the first time it will select the entire row within the Table.  Press Shift+Space a second time and it will select the entire row in the worksheet.

The same works for columns.  Ctrl+Space will select the column of data in the Table.  Pressing the keyboard shortcut a second time will include the column header of the Table in the selection.  Pressing Ctrl+Space a third time will select the entire column in the worksheet.

You can select multiple rows or columns by holding Shift and pressing the Arrow Keys multiple times.

4 0
1 year ago
Other questions:
  • Pls help me. ask yourself what would jesus do...
    14·1 answer
  • Lucas put a lot of thought into the design for his company's new white paper. He made sure to include repeating design elements
    13·2 answers
  • 4.2.3: Basic while loop expression. Write a while loop that prints userNum divided by 2 (integer division) until reaching 1. Fol
    6·2 answers
  • Suppose a host has a 1-MB file that is to be sent to another host. The file takes 1 second of CPU time to compress 50%, or 2 sec
    12·1 answer
  • How would GIS, GPS, or remote sensing technology be used to evaluate the destruction caused by a tornado in Oklahoma?
    13·1 answer
  • Insert the missing code in the following code fragment. This fragment is intended to call the Vehicle class's method. public cla
    14·1 answer
  • Write multiple if statements: If carYear is before 1968, print "Probably has few safety features." (without quotes). If after 19
    6·1 answer
  • 14. Emelia is very concerned about safety and has conducted a study to determine how many bike helmets were replaced at each loc
    13·2 answers
  • A third-grade teacher at Potter Elementary School wants a program that allows a student to enter the amount of money a customer
    14·1 answer
  • What web 2.0 features allows users to subscribe to a data plan that charges for the amount of time spent on the internet?
    9·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!