Asked Sep 27, 2019
  1. Write a program that takes four int command-line arguments w, x, y, and z. Define a boolean variable whose value is true if the four values are either in strictly ascending order (w < x < y < z) or strictly descending order (w > x > y > z), and false otherwise. Then, display the boolean variable value.
  1. NOTE 1: Do not use if statements on this program.
  2. NOTE 2: Assume that the inputs will always be integers.

Expert Answer

Step 1

Program Design

The program receives 4 integers at command prompt and ascertains if the numbers are in strict ascending or descending order in an expression built with a combination or logical and relational operators. The result of the expression is printed out.

Step 2



import java.util.Scanner;

class OrderCheck{

                public static void main(String args[]){

                                //prompt user for input

                                System.out.println("Enter four numbers below");

                                //declare scanner variable to receive command line inputs

                                Scanner in = new Scanner(;

                                //read the inputs into int variables

                                int w = in.nextInt();

                                int x = in.nextInt();


Want to see the full answer?

See Solution

Check out a sample Q&A here.

Want to see this answer and more?

Solutions are written by subject experts who are available 24/7. Questions are typically answered within 1 hour.*

See Solution
*Response times may vary by subject and question.

Related Computer Science Q&A

Find answers to questions asked by student like you
Show more Q&A

Q: Convert the grammar S → aSb|bSa|a|b|ab into Greibach normal form.

A: A context free grammar  is in Greibach Normal Form (GNF) if all production rules satisfy one of the ...


Q: What are the risks associated with a pervasive security infrastructure? What are the reasons for NOT...

A: Pervasive security infrastructure refers to cloud security risks. As many users possibly from differ...


Q: Write a GUI application that calculates a car’s gas mileage. The application should let the user ent...

A: Create the MPGCalculator class and declare the given fields along with two JPanel gallonsLabel and m...


Q: Construct npda that accept the following languages on Σ = {a, b, c}: L = {anb3n : n ≥ 0}.

A: To construct the NPDA of the language L = {anb3n : n ≥ 0} on Σ = {a, b, c}, we will draw a machine l...


Q: In C++ programming. Below is the UAH_sample.txt The University of Alabama in Huntsville was founded ...

A: Since the program is quite complex we are answering only the first part due to lack of space, it is ...


Q: Use the worksheets to show, one path augmentation at a time, how to use the Ford-Fulkerson Algorithm...

A: For solving your problem first of all we define Ford-Fulkerson Algorithm.Ford-Fulkerson Algorithm fo...


Q: Hi,  Please,I have a question with Python,I have to create a Loop and terminate BMI calculation flow...

A: The loop of flow chart for BMI is given as:


Q: How to use the i.t. simulation viewer?

A: IT simulation viewers are the software that allows one to view and run simulations created in the si...


Q: Create a new file (in Dev C++) . In Lab 2, you created a menu for a simple calculator program. In La...

A: Program Instructions:Declare variables and call the printHelloMsg() function to display a welcome me...