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

  Program that recursive function to print a string backwards

modify a program that uses a recursive function to print a string backwards. Your program must contain a recursive function that prints the string backwards. Do not use any global variables; use appropriate parameters.

  Discuss disadvantages of each type of refresh technique

Why is RAS*-oniy refreshing now less popular than CAS*-before-RAS* refreshing? Why does the CAS*-only refresh make it easy to design a refreshing system?

  Design combinational circuit with three input and six output

Design a combinational circuit with three inputs and six outputs. The output binary num-ber should be the square of the input binary number.

  Why are gaap and gaas important to the it auditor

Why are GAAP and GAAS important to the IT auditor? What and where are the resources available to train auditors, especially IT auditors?

  Design a set of powerpoint slides explaining

Jim and Tim are brothers who have a love of robots. They started a home based business known as 'RoboBoys' where they custom build robots for fun, gifts, competition and decoration.

  Provide functionality for insertion alongside edition

provide functionality for insertion alongside edition and deletion. Implement field checking for empty fields. -We talked about this on slides and the video contains some information regarding this- Create another table called Admin and include col..

  What is generally not tracked in change management database

What is generally not tracked in a change management database? When performing a security assessment, using a framework such as NIST 800-15, which is generally the first step?

  Identify and describe the changes in business communications

Identify and describe the changes in business communications that have resulted from the transition from paper to the electronic medium.

  How do you test whether at least one of x and y is zero

How do you test whether at least one of them is zero? How do you test whether exactly one of them is zero? What is the value of !!frozen?

  Discuss technological and financial risks in detail

Company M designs manufacture and sells electronic door locks for commercial buildings. The company has approximately 1,500 employees in three locations.

  What preventive maintenance tasks need to be scheduled what

1.describe final system acceptance criteria2.resources were the right personnel assigned to the project?3.what are some

  Draw a diagram to illustrate each of the given triplets

Draw a diagram to illustrate each of the following triplets. The first element in each triplet is a lower bound, the second element is an upper bound.

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