Determine the lexicographic order of the names

Assignment Help Computer Engineering
Reference no: EM132085789

Open a JOptionPane confirm dialog as shown on Figure 1 below. This dialog box is a graphical embodiment of the if-else logic. However, the button clicks of this window return integer values, not a boolean value or String. Follow the template exactly. The syntax is similar to that of the other dialogs:

JOptionPane.showConfirmDialog(null, <ask for a choice here>,    <title line here>, JOptionPane.YES_NO_OPTION);

Note that a button click makes this method return an integer number which is one of the two named constants

JOptionPane.YES_OPTION or JOptionPane.NO_OPTION

Assign the return value to an integer variable like

int choice = JOptionPane.showConfirmDialog(null,etc)

(1pt) Using an if statement like

if(choice == JOptionPane.NO_OPTION)

you check if choice is the No option, in that case send the message

The program terminates!

to the console and terminate the program with the System.exit(0) statement.

Otherwise do as follows:

Solicit three names written in a row to a JOptionPane input window as shown in

Figure 2. Each name must be one word and the words are separated by spaces. Follow the template layout accurately, but you can choose other names. Save the return value in a variable named names. Remember, the input window returns a string.

Validate the input: null string or empty string is not accepted for names. Use the same if logic as in Lab 4, in the if block print the message

"Input is not valid, program terminates"

to the console and terminate the program.

Otherwise do as follows to learn a new Scanner property:

Declare three String variables name1, name2 and name3 to serve as the storage for the individual names from the input

Declare and instantiate a Scanner reference splitter as in your previous assignments, but this time write in the constructor for parameter the variable names (rather than System.in). Here is the code for the instantiation (do not forget to import the util package above the class header):

Scanner splitter = new Scanner(names);

Apply the method call splitter.next( ) three times and save the return values one after each other in the variables name1,name2 and name3, respectively

Create an if-else logic to determine the lexicographic order of the names. This logic is supposed to be the same as the one you implemented in the incomplete version.

For this purpose use the compareTo method of the String class with the 'ignore case' option (see the book p 150); declare and use additional helper variables if needed. There are six possible orders for three names, your selection logic must cover all six of of them.

If you did Lab 5 Incomplete, you can use your code solving the book Programming Challenge 7.

(1pt) Collect and save the names in correct order in a single String variable namesOrdered

(1pt) Display the variable namesOrdered on a message dialog.

(1pts) Test your program for each of the 6 possible arrangements of three input words (you may use short words for testing purposes like "Abe" "Bo" "Cy".

Reference no: EM132085789

Questions Cloud

What amount of the proceeds from the issuance : What amount, if any, of the proceeds from the issuance should be accounted for as part of Gordon's stockholders' equity
Provide a default constructor that sets the id number : Open the file TestBloodData.java and click the "Run Code" button to demonstrate that each method works correctly.
What are the two models of interprocess communication : What are the two models of interprocess communication? What are the strengths and weaknesses of the two approaches?
How much of these losses can cindy deduct : Cindy's share of the LLC s losses was $85,000 in 2014 and $45,000 in 2015. How much of these losses can Cindy deduct
Determine the lexicographic order of the names : Create an if-else logic to determine the lexicographic order of the names. This logic is supposed to be the same as the one you implemented in the incomplete ve
How much of the charitable contribution should pat deduct : Pat had AGI of $300,000. In completing her income tax return, how much of the charitable contribution should Pat deduct
Why do these three commands return the result they do : Why do these three commands return the result they do? Do all of the tools retrieve the information from the same place?
Integrate some code into your checkout program : ITECH1400 – Foundations of Programming - Supermarket Self-Service Checkout - Analyse to determine what they do & provide documentation comments
Compare harry potter to bilbo baggins : Compare Harry Potter to Bilbo Baggins. Which is the more typical mythological hero and why?

Reviews

Write a Review

Computer Engineering Questions & Answers

  Mathematics in computing

Binary search tree, and postorder and preorder traversal Determine the shortest path in Graph

  Ict governance

ICT is defined as the term of Information and communication technologies, it is diverse set of technical tools and resources used by the government agencies to communicate and produce, circulate, store, and manage all information.

  Implementation of memory management

Assignment covers the following eight topics and explore the implementation of memory management, processes and threads.

  Realize business and organizational data storage

Realize business and organizational data storage and fast access times are much more important than they have ever been. Compare and contrast magnetic tapes, magnetic disks, optical discs

  What is the protocol overhead

What are the advantages of using a compiled language over an interpreted one? Under what circumstances would you select to use an interpreted language?

  Implementation of memory management

Paper describes about memory management. How memory is used in executing programs and its critical support for applications.

  Define open and closed loop control systems

Define open and closed loop cotrol systems.Explain difference between time varying and time invariant control system wth suitable example.

  Prepare a proposal to deploy windows server

Prepare a proposal to deploy Windows Server onto an existing network based on the provided scenario.

  Security policy document project

Analyze security requirements and develop a security policy

  Write a procedure that produces independent stack objects

Write a procedure (make-stack) that produces independent stack objects, using a message-passing style, e.g.

  Define a suitable functional unit

Define a suitable functional unit for a comparative study between two different types of paint.

  Calculate yield to maturity and bond prices

Calculate yield to maturity (YTM) and bond prices

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd