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]
4 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]4 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
Green computing can be achieved by: a. using video conferencing, electronic meeting systems, and groupware. b. replacing meeting
Rama09 [41]

Answer: using video conferencing, electronic meeting systems, and groupware

Explanation:

Green computing simply means the use of computer in a way that's environmental friendly.

One way to achieve this is through using video conferencing, electronic meeting systems, and groupware. This allows the use of computers not to have a negative effect on the environment.

4 0
3 years ago
Convert 10101010 into decimal number system​
geniusboy [140]

Answer:

170 hope this helps you with

3 0
3 years ago
Read 2 more answers
Name two driving factors in the development of computers.
sertanlavr [38]

The two driving factors in the development of computers are the  Skill set of the team. [If the team is well versed in a specific stack, then the performance will be good as compared to any other stack].

<h3>What re the matters?</h3>

There are some matters to consider. For business programs, I'd say gaming. A lot of what the common laptop makes use of for enterprise doesn't require that kind of electricity.

  1. The skill set of the team. [If the team is well versed in a specific stack, then the performance will be good as compared to any other stack]
  2. Process familiarity. [If dev team knows the stack but the deployment/service team is new, then you may run into deployment and maintenance issues.]

Read more about the computers:

brainly.com/question/24540334

#SPJ1

8 0
2 years ago
What is the best way to determine if a cable inside a computer is a data and instruction cable or a power cable?
Liono4ka [1.6K]
You have to trace it back to its source to determine it. Data cables are flat and cables are round.
4 0
3 years ago
2. Part of a pie chart that represents one value from the series.
mina [271]

......................

A. Axis

4 0
3 years ago
Other questions:
  • Perform online research and learn about the elements of a presentation program interface not discussed in the lesson. Write a sh
    9·1 answer
  • What type of software translates a programmer’s statements to binary form?
    10·1 answer
  • Can someone help me out with this one? I'm not sure why my code is not working
    11·1 answer
  • Parts are described by partnum, color, and price. Parts can be subassemblies as well and this means that they contain other part
    12·1 answer
  • Select the organizational skills that can help with
    6·1 answer
  • A customer has a computer for a home business, but wants to have another computer as a web server. What would be the best soluti
    11·2 answers
  • Which type of storage disk and disk drive can you use in the given situation?
    9·1 answer
  • 1 Which of the following could work as bits for a binary system?
    9·1 answer
  • In a ________ system configuration, separate information systems are designed and managed by each foreign unit.
    5·1 answer
  • What was Ada Lovelace's contribution to computer science?
    13·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!