Answered step by step
Verified Expert Solution
Question
1 Approved Answer
The program should display the three names arranged in the specified sort order of their lengths. i.e. first, display the name with the least number
The program should display the three names arranged in the specified sort order of their lengths. i.e. first, display the name with the least number of characters, and so on. We can't use arrays but I don't know how to get the compareTo or equals function to work for this problem.
import javax. swing.JOptionPane; /eeded for dialog boxes public class firstmiddlelastnames f public static void main String args) String first; first JOptionPane. showInputDialogC"Enter your first name."; // prompts user to enter their first name String middle; middle JOptionPane. showInputDialogC" Enter your middle name."); String last; last JOptionPane.showInputDialogC"Enter your last name." String order; order-J0ptionPane.showInputDialogC"Enter the sorting order, 1 for ascending and 2 for descending order."); /USE COMPARETO OR EQUALS CNOT AS A HELP NO ARRAYSStep by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started