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 a brainpop acct. can i pls use it !
RSB [31]

Answer:

Союз нерушимый республик свободных

Сплотила навеки Великая Русь.

Да здравствует созданный волей народов

Единый, могучий Советский Союз!

Славься, Отечество наше свободное,

Дружбы, народов надежный оплот!

Знамя советское, знамя народное

Пусть от победы, к победе ведет!

Сквозь грозы сияло нам солнце свободы,

И Ленин великий нам путь озарил.

Нас вырастил Сталин - на верность народу

На труд и на подвиги нас вдохновил.

Славься, Отечество чаше свободное,

Счастья народов надежный оплот!

Знамя советское, знамя народное

Пусть от победы к победе ведет!

Skvoz grozy siialo nam solntse svobody,

I Lenin velikij nam put ozaril.

Nas vyrastil Stalin - na vernost narodu

Na trud i na podvigi nas vdokhnovil.

Slavsia, Otechestvo chashe svobodnoe,

Schastia narodov nadezhnyj oplot!

Znamia sovetskoe, znamia narodnoe

Pust ot pobedy k pobede vedet!

Мы армию нашу растили в сраженьях,

Захватчиков подлых с дороги сметем!

Мы в битвах решаем судьбу поколений,

Мы к славе Отчизну свою поведем!

Славься, Отечество наше свободное,

Славы народов надежный оплот!

Знамя советское, знамя народное

Пусть от победы к победе ведет!Explanation:

8 0
3 years ago
How can you continue learning about computer science and improve your coding abilities?
Crank

Answer:

5 Ways to Improve Your Coding and Programming Skills

Take advantage of books and other free resources. ...

Sign up for a bootcamp. ...

Practice, practice, practice. ...

Engage with the computer science community. ...

Pursue a formal education in computer science.

7 0
3 years ago
If an if- else statement is true, it will include which kinds of results?
Salsk061 [2.6K]

In an if...else statement, if the code in the parenthesis of the if statement is true, the code inside its brackets is executed. But if the statement inside the parenthesis is false, all the code within the else statement's brackets is executed instead.

Of course, the example above isn't very useful in this case because true always evaluates to true. Here's another that's a bit more practical:

#include <stdio.h>

int main(void) {

int n = 2;

if(n == 3) { // comparing n with 3 printf("Statement is True!\n");

}

else { // if the first condition is not true, come to this block of code

printf("Statement is False!\n"); } return 0;

}

Output:

Statement is False!

5 0
2 years ago
Identify the components of the enveloped virus budding process
Elina [12.6K]

The components of the enveloped virus budding process are:

  • lipid bilayers
  • fission event
  • Glycosylated (trans-) membrane proteins.

<h3>What is the case of the virus about?</h3>

Virus budding in general is known to be a term that connote the scattering or disturbance of a cellular membrane and it is one away from the cytoplasm.

Note that it is said to be the envelopment of the viral capsid and this is done by one or more lipid bilayers that can be seen in the viral membrane glycoproteins, and it is one where a fission event takes place.

Hence The components of the enveloped virus budding process are:

  • lipid bilayers
  • fission event
  • Glycosylated (trans-) membrane proteins.

Learn more about virus from

brainly.com/question/26128220

#SPJ1

3 0
1 year ago
What is an instance of a computer program that is being executed?
Lostsunrise [7]
It is processing because it is processing the data on the program.
7 0
3 years ago
Other questions:
  • Text, numbers,graphics, sounds entered into a computer's memory during input operations are referred to as
    11·1 answer
  • Use the _______ command to combine the selected cells and center them. merge across center across selection merge cells merge an
    7·1 answer
  • The next four octal numbers after 36 is:________.
    10·1 answer
  • What quantities are measured by the following sensors:
    9·1 answer
  • Create an application named TurningDemo that creates instances of four classes: Page, Corner, Pancake, and Leaf. Create an inter
    7·1 answer
  • Should a waiting thread receive priority over a thread first attempting to enter a monitor? What priority scheme, if any, should
    9·1 answer
  • Melanie needs to ensure that readers are able to locate specific sections within a document easily. What should she include in
    8·1 answer
  • Son opciones de configuración espacio multimedia llamado blog
    9·1 answer
  • Write a method doubleUp that doubles the size of a list of integers by doubling-up each element in the list. Assume there's enou
    13·1 answer
  • Which of the following is NOT one of the three main ways to control a program when writing code?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!