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
BigorU [14]
3 years ago
5

Write a program TwoSmallest.java that takes a set of double command-line arguments and prints the smallest and second-smallest n

umber, in that order. It is possible for the smallest and second-smallest numbers to be the same (if the sequence contains duplicate numbers).
Computers and Technology
1 answer:
aliina [53]3 years ago
7 0

Answer:

The following code is written in java programming language:

public class TwoSmallest {   //define class

   public static void main(String[] args) {     // define main function

       if (args.length < 2) {     //set the if condition

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

       } else {

           double minimum1 = Double.parseDouble(args[0]), minimum2 = Double.parseDouble(args[1]), n;

           if (minimum1 > minimum2) {    //set the if condition

               double temp = minimum1;

               minimum1 = minimum2;

               minimum2 = temp;

           }

           for (int i = 2; i < args.length; i++) {      //set the for loop

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

               if (n < minimum1) {

                   minimum2 = minimum1;

                   minimum1 = n;

               } else if (n < minimum2) {

                   minimum2 = n;

               }

           }

           System.out.println(minimum1);

           System.out.println(minimum2);

       }

   }

}

Explanation:

Here, we define a class "TwoSmallest" with public modifier.

Then, we define the main method.

Then, we set if condition and pass condition "args.length < 2".

Then we take three double type variable "minimum1", "minimum2" and "n".

Then, we set the if condition and pass condition if "minimum1 > minimum2", then set double type "temp" variable and swap between temp, minimum1 and minimum2.

Then, we set the for loop which is start from 2 and stops at "args.length"

Then, we set if condition and then we set its else part, after that we print the value of minimum1 and minimum2.

You might be interested in
PLEASE HELP there are TWO ANSWERS
pickupchik [31]

Answer:

Pero un campo cuyo tipo de datos es Número solo puede almacenar datos numéricos. ... Por ejemplo, los valores que se almacenan en un campo Texto solo pueden contener ... Para más información, haga clic en los tipos de datos siguientes. ... Controla la conversión de frases en las versiones asiáticas de Windows.

5 0
3 years ago
[ASAP] Choose the tool that best matches each description.
vazorg [7]

Answer: BeeWare​ is an open-source library that can be used to develop mobile apps in Python, where all of the objects look the same, no matter what platform it is displayed on. In contrast, the Kivy library uses native objects, so that applications built with it will look like other apps on that platform.

Explanation:

4 0
2 years ago
Which IPsec security function provides assurance that the data received via a VPN has not been modified in transit?
Anit [1.1K]

<u>Integrity IPsec security</u> function provides assurance that the data received via a VPN has not been modified in transit.

<u>Explanation:</u>

IPsec utilizes cryptographic security administrations to ensure interchanges over Internet Protocol (IP) systems. It underpins organize level friend validation, information beginning confirmation, information honesty, information classification (encryption), and replay assurance. ESP gives confirmation, respectability, and secrecy, which ensure against information altering and, in particular, give message content security.

Moreover, parcels that are not confirmed are disposed of and not conveyed to the planned recipient. ESP likewise gives all encryption benefits in IPSec. IPsec Authentication Header (AH), IPsec Encapsulating Security Payload (ESP), and the IPsec Internet Key Exchange (IKE). for both IPv4 and IPv6 systems, and activity in the two adaptations is comparative.

3 0
3 years ago
Catherine took her camera to the repair shop. The technician at the shop told her that acid had leaked into her camera. What cou
tino4ka555 [31]

Answer:

B

Explanation:

3 0
3 years ago
You will write a flowchart and C code for a program that does the following:Call three functions from main(). The functions are
Vitek1552 [10]

Answer:

#include <stdio.h>

void first() {

   printf("first\n");

}

void second() {

   printf("second\n");

}

void third() {

   printf("third\n");

}

int main() {

   first();

   second();

   third();

   printf("End of program.\n");

   return 0;

}

8 0
3 years ago
Other questions:
  • PLEASE HELP ASAP!!!
    15·2 answers
  • Industrial Products is a small light-manufacturing firm that produces a variety of control systems for heavy industry. It has a
    13·1 answer
  • Search the internet for news of a motor vehicle collision in your community involving drugs or alcohol. Keeping in mind that you
    8·1 answer
  • Sharon is a skilled professional who operates logging equipment.
    12·2 answers
  • Describe the major research, discoveries, or impact Timothy Berners-Lee has made on the scientific community. 100 points for ans
    6·1 answer
  • When an attacker promotes themselves as reputable third-party advertisers to distribute their malware through the Web ads,
    15·1 answer
  • What are the best 3 xbox 360 games ?​
    10·2 answers
  • A law office has been leasing dark fiber from a local telecommunications company to connect a remote office to company headquart
    14·1 answer
  • In cell I8, enter a nested logical function to display Need to Remodel if the apartment is unoccupied (No) AND was last remodele
    9·1 answer
  • What should you do to organize a large amount of data??
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!