Copy the skeleton of code below into your answer. Then in the space indicated, add your own code to prompt the user for two Strings, report on the lengths of the two Strings, and then print the...

1 answer below »

Copy the skeleton of code below into your answer. Then in the space indicated, add your own code to prompt the user for two Strings, report on the lengths of the two Strings, and then print the shorter of the two strings as part of an output message as indicated below. If they are both the same length print the first one. Note that the final output should be on a line by itself.


Enter a String:
CSE1223

Enter another:
1223

Your first has 7 characters.
Your second has 4 characters.
The shorter one is 1223

A second run of this program with different input might look like this:


Enter a String:
CSE1223

Enter another:
Java_CSE1223

Your first has 7 characters.
Your second has 12 characters.
The shorter one is CSE1223

Use the skeleton of the main method below to write your code.


public static void main(String[] args) {
Scanner input = new Scanner(System.in);
// TODO: Your code below this line
input.close();
}


Answered Same DaySep 16, 2021

Answer To: Copy the skeleton of code below into your answer. Then in the space indicated, add your own code to...

Arun Shankar answered on Sep 16 2021
136 Votes
import java.util.Scanner;
public class Main
{
    public static void main(String[] args)
    {
        Scan
ner input = new Scanner(System.in);
        // TODO: Your code below this line
        
        System.out.print("Enter a String: ");
        String a = input.nextLine();
        
        System.out.print("Enter another:...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here