Question: With your partner, you will be writing two methods to submit in this lab. This code is directly relevant to the next project, so you

 With your partner, you will be writing two methods to submit

With your partner, you will be writing two methods to submit in this lab. This code is directly relevant to the next project, so you should make sure that both you and your partner have copies of the lab before you leave today. The first method you will be writing will prompt the user for a value until a valid value has been entered. The second will take the value input by the user and reverse it. The program In Eclipse, create a new class named ReverseStrings, then cut and paste the class skeleton below into your new class: * Program to reverse a String entered by a user. * @author YOUR NAME HERE * @author YOUR PARTNER NAME HERE * @version TODAY'S DATE HERE import java.util.Scanner; public class ReverseStrings { * Prompts the user for input repeatedly until the user enters a non-empty * String. * @param in the Scanner object to be used to read user input * @return the String entered by the user */ public static String getUserInput(Scanner in) { // TODO - complete this function // TODO - the following line is only here to allow this program to // compile. Replace it and remove this comment when you complete // this method. return""; * Returns the reverse of the input String inString. * @param inString the String to be reversed * @return the reverse of inString */ public static String reverse(String inString) { // TODO - complete this function // TODO - the following line is only here to allow this program to // compile. Replace it and remove this comment when you complete // this method. return""; public static void main(String[] args) { // Set up the scanner Scanner inScanner = new Scanner(System.in); // Prompt the user for input String input = getUserInput(inScanner); // Reverse the user's input String reversed = reverse(input); // Display the result System.out.println("You typed: " + input); System.out.println("In the mirror, that is " + reversed); inScanner.closeO; Fill in the author names and the date. Then look over the main method of this program - make sure you understand what it is trying to do. In particular, make sure you understand how the main method performs each of the following steps: 1. Creating the Scanner object. 2. Getting input from the user by calling the getInput method with the Scanner object as a parameter. 3. Getting the reverse of the user's input by calling the reverse method with the user's input as a parameter. Then write the method getUserInput. This method should prompt the user to enter a String - if the user enters an empty line, they should receive an error message and the prompt should repeat. For example: Enter a non-empty string: ERROR - you must enter a non-empty string! Enter a non-empty string: hello In the above example, the user first entered a blank like by hitting Enter, received an error message, then typed the word "hello" when prompted again and the method ended. You must write your method to have that same behavior. Test your code by running the program - you won't get the correct output yet, but you should at least see that the prompt works correctly

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!