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
Explain the concept of an engineering trade-offs and give an example
makvit [3.9K]

ytfjkhm,MNbkvjhmb,kn.l">

k

8 0
4 years ago
Read 2 more answers
George wants to edit the font of the title in his presentation. Where can he find the option to edit it?
Bad White [126]

The answer could be B. Tool Bar

6 0
3 years ago
Read 2 more answers
When creating a report, you should consider all of the following EXCEPT (Points : 4) who will use the report
barxatty [35]

Answer: Number of records input into the report

Explanation: Creating the report includes the factors like maintaining the record, updating data, designing content etc. The content of the report has the parameter to maintain so that it can be up to date and can be efficient to the user.

The parameters that are considered while making the report are confidential content should be specially considered ,user of the report , purpose of the report,etc. The only factor that is not accountable is input.There can be number of inputs that can be entered in the report because they have huge sheet space.

8 0
3 years ago
How much KB would be if I have 1,234.MG?
Veseljchak [2.6K]
You would have 1234000 Megabytes
7 0
4 years ago
Read 2 more answers
When creating a documentary, what is not an appropriate source for footage?
Lorico [155]
The answer to this is similar documentaries on youtube!! Hope i helped
3 0
3 years ago
Other questions:
  • Why is it important to be a good digital citizen??
    11·1 answer
  • What is the encryption cipher that was the precursor to des??
    5·1 answer
  • Consider a system that uses a 32-bit unique salt where users have a 4-digit number as a password (e.g. 6813). Eve wants to crack
    8·2 answers
  • View the attached picture
    7·1 answer
  • When discussing the business requirements of a WLAN design, what is the first question that should be posed
    15·1 answer
  • What does it mean to be a good cyber citizen?
    8·2 answers
  • which of the following devices and and receive information from other device? a parallel port B serial port C video port d both
    8·1 answer
  • Please answer this now I need please.
    5·1 answer
  • What do you think that the next version of IR (IR 5.0) will bring if it was discovered in near future? (hint:- advance IR 4.0 fe
    8·1 answer
  • are you in active recovery from a substance use disorder (addiction)? active recovery is defined as being free from an alcohol o
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!