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
A network is a group of two or more computers or devices connected together. To be able to connect, they each need a
Kay [80]
D. Internet service protocol (isp)
6 0
3 years ago
Read 2 more answers
According to the SANS Institute, a __________ is typically a document that outlines specific requirements or rules that must be
nata0808 [166]
That’s should be in the quizlet I think..
7 0
3 years ago
How to keep tools and equipment safeuh​
ivanzaharov [21]

Answer:

Use pelican, or similar heavy duty cases

Explanation:

Pelican is a brand btw. 10/10 would recommend

8 0
3 years ago
Read 2 more answers
Northern Trail Outfitters uses a custom object Invoice to collect customer payment information from an external billing system.
Kobotan [32]

An administrator should ensure this requirement by creating a process builder to set the field.

<h3>What is a billing system?</h3>

A billing system is a complex software that enables service providers' order to cash process (O2C) and sends invoices, tracks, and processes payments for different consumers.

It is the process by which a business bills and invoices customers. Billing systems often include payment software that automates the process of collecting payments, sending out recurring invoices, expense tracking, and invoice tracking.

Learn more about billing system here,

brainly.com/question/14315763

#SPJ1

8 0
2 years ago
When introducing a database into an organization, the database approach creates a more controlled and structured information flo
Karolina [17]

Answer:

a.cultural

Explanation:

Cultural impact generally refers to resistance to change in DBMS.It msu be assessed carefully. The Database management system is likely to have effect on functions,people and interactions.For example:- New roles might be given to already existing persons,new people might be hired.

8 0
3 years ago
Other questions:
  • Fedora operating system
    9·1 answer
  • How to study program ?
    11·1 answer
  • What is the value of variable num after the following code segment is executed?
    5·1 answer
  • How did punch cards improve the weaving process?
    11·1 answer
  • Assume the system with 256B memory and 64B cache and the block size of 16 bytes. I.e., there are 4 blocks in the cache.
    12·1 answer
  • What is cyber ethics​
    10·2 answers
  • Explain steps in creating a main document for from letter. <br>​
    5·1 answer
  • Any please answer this How much resistance is required to gen-erate 50 mA of current from a 5 volt bat-tery?
    5·1 answer
  • Give one (1) advantage and one(1) disadvantage of using and integrated software package over a custom written one.
    15·1 answer
  • What is output by the following code?
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!