1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
Julli [10]
3 years ago
14

two Smallest (10 points). Write a program TwoSmallest.java that takes a set of double command-line arguments and prints the smal

lest and second-smallest number, in that order. It is possible for the smallest and second-smallest numbers to be the same (if the sequence contains duplicate numbers). Note: display one number per line. Hint: Double.MAX_VALUE is the largest real number that can be stored in a double variable.
Computers and Technology
1 answer:
Umnica [9.8K]3 years ago
4 0

Answer:

Below is the program TwoSmallest.java with each step explanation in form of comments.

public class TwoSmallest {                     // class definition

//main class having string args as a parameter

   public static void main(String[] args)

{ if (args.length < 2)

{         //string length must not be less than 2 for proceeding

           System.out.println("Please provide double values as command line arguments");

  }

else {  

// first two entries of string are checked for min1 and min2 and stored in variables with data type double

           double min1 = Double.parseDouble(args[0]), min2 = Double.parseDouble(args[1]), num;

//when min1 will be greater than min2 it will be stored temporary in variable temp having data type double

           if (min1 > min2) {

               double temp = min1;

               min1 = min2;

               min2 = temp;  //value of temp will be stored in min2

           }

//loop will check for each entry remaining until the last character of string

           for (int i = 2; i < args.length; i++) {

               num = Double.parseDouble(args[i]);

               if (num < min1) {

                   min2 = min1;

                   min1 = num;

               } else if (num < min2) {

                   min2 = num;

               }

           }

//min1 will give the 1st minimum number and min2 will give 2nd minimum.

           System.out.println(min1);

           System.out.println(min2);  

//both characters will be printed in sequence

       }

   }

}

You might be interested in
Who has the wrong anwser
Lynna [10]

Answer:

umm?

Explanation:

8 0
2 years ago
Read 2 more answers
When a user receives an email warning about the dire consequences of possible virus attacks on their pc or tablet, it is often a
Sliva [168]
Sometime it's a scam an sometimes it's true
7 0
3 years ago
What is one difference between a web page and a web application? Web pages provide information, while web applications allow the
Assoli18 [71]

Webpage is a page of a site, such as https://example.com/test, where the bolded text is the page.

On the other hand, web applications, or simply web apps, are found in many websites, such as here and also in Connexus. They end in either aspx or jsp, which stand for asp.net appx and javascript page, respectively.


So, your answer would be A: Web pages provide information, while web applications allow the user to do something.

Hope this was answer you were looking for. Have a nice day!

7 0
3 years ago
What are two software tools for bank account reconciliation?
AysviL [449]

Answer: cashbook and erp system

Explanation:

8 0
3 years ago
Read 2 more answers
What does pagination mean in Microsoft Word?
marin [14]

it means to alt f4 then that would help so it can eat the microscope then have it digested

5 0
3 years ago
Read 2 more answers
Other questions:
  • Choose the correct sequence for classifier building from the following.
    7·1 answer
  • Where can you change your web page SafeSearch settings?
    8·1 answer
  • Given positive integer numInsects, write a while loop that prints that number doubled without reaching 100. Follow each number w
    8·1 answer
  • _____ allow(s) a user to double click with the mouse in a document to move the insertion point to a new location.
    11·1 answer
  • Which of the following is the best definition of being a “digital citizen”?
    6·2 answers
  • When disabling inherited permissions on an object, what happens if you select Remove all inherited permissions from this object?
    11·1 answer
  • Vghfthcnbvhghvngjgjvjgkb, kcnjc cnnfjdhd mc Dan Jfhjc cm. Cm n n hdjfjocnkcnd
    10·2 answers
  • You are contacted by a project organizer for a university computer science fair. The project organizer asks you to hold a forum
    10·1 answer
  • The function below takes two parameters: a string parameter: csv_string and an integer index. This string parameter will hold a
    5·1 answer
  • In what ways are super computer different from mainframe computers.​
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!